Models

This page covers how kōjō calls language models: the tiers, the providers of the embedded gateway, an external OpenAI-compatible gateway, fallbacks, rate limits, budgets and prices. Read it when you install kōjō, change a model, or set spend caps.

How model calls work

Every model call goes through one model gateway inside the kōjō process (internal/models). A caller names a tier, not a model. The gateway:

  1. resolves the tier to a model and its fallbacks,
  2. waits if the tier has a requests-per-minute limit,
  3. calls the model, and tries the fallbacks in order if the call fails,
  4. prices the answer with the tier’s configured price.

One model call of a session, from the budget check the session makes first to the price:

flowchart TD
    A["A session calls a tier"] --> B{"Session or daily budget reached?"}
    B -- yes --> X["Refused: budget reached"]
    B -- no --> C["The tier resolves to its model and fallbacks"]
    C --> D["Wait for the tier's requests-per-minute slot"]
    D --> E["Call the tier's model"]
    E --> F{"Answered?"}
    F -- yes --> G["Priced with the tier's price, added to the session's cost"]
    F -- no --> H{"A fallback left?"}
    H -- yes --> I["Call the next fallback"]
    I --> F
    H -- no --> Y["The call fails, with every error joined"]

The gateway runs in one of three modes. kojo doctor reports the mode next to each tier.

Mode When What it calls
embedded models.gateway: embedded (the default) The providers, directly, through Genkit Go plugins
external models.gateway is a URL One OpenAI-compatible gateway at that URL
replay models.recordings is set, or the tiers use the mock provider Nothing. Recorded responses are replayed

Tiers

A tier is a name mapped to a model. The tiers fast and strong are required: kōjō refuses to start without both, because the engine and the built-in skills use them. You may add more tiers under other names and refer to them from a skill.

Caller Tier Set by
Orchestrator strong Fixed
Subagent of a skill fast unless the skill says otherwise model_tier in SKILL.md
Goal critic’s judge strong unless the skill says otherwise judge.model_tier in goals.yaml
Risk classifier of the merge policy fast Fixed. Runs only when the merge policy turns the classifier on
Natural-language schedule conversion fast Fixed
kojo doctor check Every configured tier, one call each Fixed

A skill that names a tier that is not configured fails at its first model call with tier "<name>" is not configured. See SKILL.md for model_tier and Merge policy for the risk classifier.

Each tier has these keys:

Key Type Default Meaning
provider string none Provider of the model. Required with the embedded gateway, ignored with an external one
model string none Model ID, passed to the provider unchanged. Required
fallbacks list of provider + model empty Models tried in order when the tier’s model fails
price.input_per_mtok number none USD per million input tokens
price.output_per_mtok number none USD per million output tokens
requests_per_minute integer 0 (no limit) Rate limit of the tier

kōjō does not check that a model ID exists. kojo doctor sends one short prompt to every tier and fails the tier’s check when the model does not answer.

Boot config and runtime config

Model settings live in two places.

Setting Where How to change it
models.gateway, models.gateway_api_key kojo.yaml Edit the file, restart
models.providers.* (API keys, URLs) kojo.yaml or environment Edit, restart
models.embedder kojo.yaml Edit the file, restart
models.recordings kojo.yaml Edit the file, restart
Tiers (provider, model, fallbacks, price, requests_per_minute) Runtime config object settings/models Dashboard, or kojo config apply
Budgets (per_session_usd, per_day_usd) Runtime config object settings/models Dashboard, or kojo config apply

models.tiers and models.budgets in kojo.yaml are initial values. On the first start kōjō copies them into the runtime object settings/models. After that the runtime object is the source of truth, and editing those two keys in kojo.yaml changes nothing on a running install. The exception is kojo eval --local, which starts from kojo.yaml with an in-memory store every time.

The runtime object is org-wide: a repository cannot override it. Changing it needs the operator role. Every change is a new revision that can be rolled back. In the dashboard it is the Models & budgets page under Settings; see the dashboard.

The Models and budgets settings page, scrolled down: the strong tier with its provider, model, prices, request limit and fallbacks, the Budgets panel with per-session, per-day and per-month caps, and a history panel with revisions on the right.
The history on the right starts with the value copied from kojo.yaml on the first start; every later change is a revision above it.

A session pins the config revisions it starts with. A tier or budget change applies to sessions that start after it, not to sessions in flight.

The runtime object, as kojo config export writes it and kojo config apply reads it:

version: 1
objects:
  - scope: org
    object: settings/models
    content:
      tiers:
        fast:
          provider: anthropic
          model: claude-haiku-5-5
        strong:
          provider: anthropic
          model: claude-opus-5-5
      budgets:
        per_session_usd: 10
        per_day_usd: 200

The full list of kojo.yaml keys is in the kojo.yaml reference, and the schema is kojo.schema.json.

The embedded gateway

With models.gateway: embedded kōjō calls the providers itself. The gateway is built on Genkit Go and uses its provider plugins.

Provider kojo.yaml key Environment variable Loaded when
anthropic models.providers.anthropic.api_key ANTHROPIC_API_KEY A key is set
openai models.providers.openai.api_key, models.providers.openai.base_url OPENAI_API_KEY, OPENAI_BASE_URL A key or a base URL is set
googleai models.providers.googleai.api_key GEMINI_API_KEY, then GOOGLE_API_KEY A key is set
vertexai models.providers.vertexai.project, .location, .base_url GOOGLE_CLOUD_PROJECT; GOOGLE_CLOUD_LOCATION, then GOOGLE_CLOUD_REGION A project and a location are set and Google Cloud credentials are found
azure models.providers.azure.endpoint, .api_key AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY An endpoint is set
bedrock models.providers.bedrock.region, .profile, .endpoint AWS_REGION, then AWS_DEFAULT_REGION A region is set and the AWS configuration loads
openrouter models.providers.openrouter.api_key OPENROUTER_API_KEY A key is set
ollama models.providers.ollama.url (default http://localhost:11434) none Always

A value in kojo.yaml wins over the environment variable. With the compose install the keys come from .env; with the Helm chart they come from the Secret named by secrets.existingSecret. See Deploy. vertexai, azure without a key, and bedrock take their credentials from the cloud’s usual sources instead; their sections below say which.

In kojo.yaml the provider name of a tier must be one of the eight above, or mock (see the replay provider); the file is rejected otherwise. A tier changed at runtime is only checked for a non-empty model, so a wrong provider name there shows up at call time and in kojo doctor.

A provider that is not set up is not a startup error, whether its key, a setting or its credentials are missing. A tier’s model whose provider is not set up is skipped at call time. When no model of the tier is usable, the call fails with provider <name> and the reason, such as has no API key configured or has no region configured. Run kojo doctor after changing keys, credentials or tiers.

The openai provider also serves any OpenAI-compatible server: set base_url to it. When a base URL is set and no key is, kōjō sends no Authorization header. Use this, or an external gateway, for vLLM, LiteLLM and other providers that have no entry in the table.

The openai and azure providers call the Chat Completions API and pass the tools there, so a tier’s model must take function calls through it. OpenAI’s model pages say which do not: gpt-6-luna takes them only with reasoning_effort set to none, which kōjō does not set, and gpt-6.1-terra takes tools through the Responses API only. gpt-6.2-astra and gpt-6.2-sol take them.

One provider

server:
  public_url: "${KOJO_PUBLIC_URL}"
  auth:
    session_secret: "${KOJO_SESSION_SECRET}"
    tokens:
      - name: admin
        token: "${KOJO_ADMIN_TOKEN}"
        role: admin

database:
  url: "${DATABASE_URL}"

models:
  gateway: embedded
  providers:
    anthropic:
      api_key: "${ANTHROPIC_API_KEY}"
  tiers:
    fast:
      provider: anthropic
      model: claude-haiku-5-5
      price:
        input_per_mtok: 0.10
        output_per_mtok: 0.50
    strong:
      provider: anthropic
      model: claude-opus-5-5
      price:
        input_per_mtok: 4
        output_per_mtok: 20
  budgets:
    per_session_usd: 10
    per_day_usd: 200

sandbox:
  driver: sbx

The prices in this example are placeholders. Replace them with the prices of your provider’s price list.

The providers block is optional here: without it kōjō reads ANTHROPIC_API_KEY from the environment.

Two providers with fallback

server:
  public_url: "${KOJO_PUBLIC_URL}"
  auth:
    session_secret: "${KOJO_SESSION_SECRET}"
    tokens:
      - name: admin
        token: "${KOJO_ADMIN_TOKEN}"
        role: admin

database:
  url: "${DATABASE_URL}"

models:
  gateway: embedded
  providers:
    anthropic:
      api_key: "${ANTHROPIC_API_KEY}"
    openai:
      api_key: "${OPENAI_API_KEY}"
  tiers:
    fast:
      provider: anthropic
      model: claude-haiku-5-5
      requests_per_minute: 120
      fallbacks:
        - provider: openai
          model: gpt-6.2-sol
    strong:
      provider: anthropic
      model: claude-opus-5-5
      requests_per_minute: 30
      fallbacks:
        - provider: openai
          model: gpt-6.2-astra
  budgets:
    per_session_usd: 10
    per_day_usd: 200

sandbox:
  driver: sbx

Local Ollama

server:
  public_url: "${KOJO_PUBLIC_URL}"
  auth:
    session_secret: "${KOJO_SESSION_SECRET}"
    tokens:
      - name: admin
        token: "${KOJO_ADMIN_TOKEN}"
        role: admin

database:
  url: "${DATABASE_URL}"

models:
  gateway: embedded
  providers:
    ollama:
      url: http://localhost:11434
  tiers:
    fast:
      provider: ollama
      model: nemotron-3.5-lightning:30b
    strong:
      provider: ollama
      model: qwen3.8:27b
  budgets:
    per_session_usd: 10
    per_day_usd: 200

sandbox:
  driver: sbx

Pull the models into Ollama first. Pick models that support tool calling: the orchestrator and the subagents work through tool calls.

No API key is needed, and no provider is contacted outside your network. The tiers above have no price, so every call costs 0 USD and the budgets never trigger; see prices and cost.

kōjō does not set the Genkit Ollama plugin’s request timeout, so the plugin’s default of 30 seconds per request applies.

Gemini on Vertex AI

vertexai calls Gemini through Google Cloud’s Vertex AI, with Google Cloud credentials instead of a Gemini API key. googleai stays the provider for an API key.

models:
  gateway: embedded
  providers:
    vertexai:
      project: acme-models
      location: global
  tiers:
    fast:
      provider: vertexai
      model: gemini-4-hydrogen
    strong:
      provider: vertexai
      model: gemini-4-carbon
  budgets:
    per_session_usd: 10
    per_day_usd: 200

This fragment goes inside a complete kojo.yaml.

Key Default Meaning
project GOOGLE_CLOUD_PROJECT The Google Cloud project ID.
location GOOGLE_CLOUD_LOCATION, then GOOGLE_CLOUD_REGION A region such as us-central1, a multi-region (us, eu) or global.
base_url derived from the location Another endpoint, such as a Private Service Connect endpoint. Requests keep the project and the location in their path.

kōjō calls the Vertex AI API at version v1beta1, the version Genkit’s plugin is written against, whatever the genai SDK’s default or GOOGLE_GENAI_API_VERSION says. A model is a Gemini model ID; the provider serves Google’s own models, not the partner models of the Model Garden.

The credentials are Google’s Application Default Credentials, looked up when kōjō starts:

  • One VM: a service account key file named by GOOGLE_APPLICATION_CREDENTIALS, or gcloud auth application-default login for the user kōjō runs as. On a Compute Engine VM, the VM’s service account through the metadata server.
  • GKE: Workload Identity Federation for GKE. Grant the Kubernetes service account of the kōjō pods a role that may call Vertex AI, such as roles/aiplatform.user, or link it to an IAM service account that has one with the annotation iam.gke.io/gcp-service-account (serviceAccount.annotations in the Helm chart).

Without credentials the provider is not set up, and its models fail with found no Google Cloud credentials.

Azure OpenAI and Microsoft Foundry

azure calls an Azure OpenAI or Microsoft Foundry resource through its OpenAI-compatible v1 API, at <endpoint>/openai/v1/, with Genkit’s OpenAI-compatible plugin. A tier’s model is the name of a deployment, which you choose when you deploy a model, not the model’s ID: kōjō sends it as the request’s model. The v1 API needs no api-version.

models:
  gateway: embedded
  providers:
    azure:
      endpoint: https://acme-ai.openai.azure.com
      api_key: "${AZURE_OPENAI_API_KEY}"
  tiers:
    fast:
      provider: azure
      model: kojo-fast # your deployment of gpt-6.2-sol
    strong:
      provider: azure
      model: kojo-strong # your deployment of gpt-6.2-astra
  budgets:
    per_session_usd: 10
    per_day_usd: 200

This fragment goes inside a complete kojo.yaml.

Key Default Meaning
endpoint AZURE_OPENAI_ENDPOINT https://<resource>.openai.azure.com for Azure OpenAI, or https://<resource>.services.ai.azure.com for Microsoft Foundry. An endpoint that already ends in /openai/v1 is used as it is. It must be https, except on a loopback host.
api_key AZURE_OPENAI_API_KEY A key of the resource, sent in the api-key header. Without one, kōjō uses Microsoft Entra ID.

Without a key, kōjō gets a Microsoft Entra ID token for the scope https://ai.azure.com/.default and sends it as a bearer token, fetching a new one shortly before it expires. The token comes from the Azure SDK’s DefaultAzureCredential, which tries in order: a service principal in the environment (AZURE_TENANT_ID, AZURE_CLIENT_ID, and AZURE_CLIENT_SECRET or a certificate), workload identity, a managed identity, and the Azure CLI, Azure Developer CLI and Azure PowerShell logins. The identity needs a role on the resource that may call its deployments, such as Cognitive Services OpenAI User.

  • One VM: the key in .env; or, on an Azure VM, its managed identity; or az login for the user kōjō runs as.
  • AKS: the key in the Secret named by secrets.existingSecret; or Microsoft Entra Workload ID, with the service account annotation azure.workload.identity/client-id and the pod label azure.workload.identity/use: "true" (see the Helm chart).

Amazon Bedrock

bedrock calls Amazon Bedrock’s Converse API with the AWS SDK for Go, through the community Genkit plugin genkit-aws-bedrock-go. A model is a Bedrock model ID, an inference profile ID such as us.anthropic.claude-opus-5-5, or an inference profile ARN. Anthropic’s models need an inference profile ID (a global., us. or other regional prefix before the model ID): Bedrock refuses their bare model IDs for on-demand use in most regions.

models:
  gateway: embedded
  providers:
    bedrock:
      region: us-east-1
  tiers:
    fast:
      provider: bedrock
      model: us.anthropic.claude-haiku-5-5
    strong:
      provider: bedrock
      model: us.anthropic.claude-opus-5-5
  budgets:
    per_session_usd: 10
    per_day_usd: 200

This fragment goes inside a complete kojo.yaml.

Key Default Meaning
region AWS_REGION, then AWS_DEFAULT_REGION The AWS region.
profile AWS_PROFILE, then the default profile A profile of the shared AWS config files.
endpoint the region’s Bedrock Runtime endpoint Another endpoint, such as a VPC interface endpoint.

kojo.yaml holds no AWS key. The credentials come from the AWS SDK’s default chain: the environment (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN), the shared config and credentials files (including SSO profiles), web identity (AWS_ROLE_ARN and AWS_WEB_IDENTITY_TOKEN_FILE), the container credentials of ECS and EKS Pod Identity, and the EC2 instance role. They are fetched at the first call, not at start. A Bedrock API key in AWS_BEARER_TOKEN_BEDROCK is used instead of the chain; the SDK sends it over https only. The identity needs bedrock:InvokeModel on the models the tiers name.

  • One VM: on EC2, the instance role; elsewhere, a profile in ~/.aws/config of the user kōjō runs as, or the variables above in .env.
  • EKS: IAM roles for service accounts, with the service account annotation eks.amazonaws.com/role-arn; or EKS Pod Identity, with an association between the role and the kōjō pods’ service account, which needs no annotation (see the Helm chart).

Each Bedrock call times out after 10 minutes; kōjō sets this, because the plugin’s default of 30 seconds is shorter than a long answer takes. kōjō sets no maximum on the answer’s length, so the plugin asks Claude models for at most 4,096 output tokens (8,192 for some Claude 3.5 to 4 models it recognizes by name). Genkit’s Anthropic plugin uses 4,096 for the anthropic provider as well.

An external gateway

Set models.gateway to the base URL of an OpenAI-compatible gateway and kōjō sends every model call there instead of to the providers. hikyaku is one such gateway. The URL is the API base, including a path such as /v1 when the gateway serves under one.

server:
  public_url: "${KOJO_PUBLIC_URL}"
  auth:
    session_secret: "${KOJO_SESSION_SECRET}"
    tokens:
      - name: admin
        token: "${KOJO_ADMIN_TOKEN}"
        role: admin

database:
  url: "${DATABASE_URL}"

models:
  gateway: http://hikyaku:8080/v1
  gateway_api_key: "${MODEL_GATEWAY_API_KEY}"
  tiers:
    fast:
      model: claude-haiku-5-5
    strong:
      model: claude-opus-5-5
      fallbacks:
        - model: gpt-6.2-astra
  budgets:
    per_session_usd: 10
    per_day_usd: 200

sandbox:
  driver: sbx

With an external gateway:

  • The gateway routes on the model name alone. provider in a tier or a fallback is not validated and not sent.
  • models.gateway_api_key is sent as a bearer token. Without it kōjō sends no Authorization header.
  • models.providers.* and the provider environment variables are not read.
  • Tiers, fallbacks, requests-per-minute limits, prices and budgets still work in kōjō as described on this page. A fallback is another model name sent to the same gateway.
  • kojo doctor shows the gateway URL as the mode.

Fallbacks

fallbacks is an ordered list of models for a tier. When a call to the tier’s model returns an error, kōjō logs a warning and sends the same request to the next model in the list. It stops at the first model that answers. When all fail, the call fails with every error joined.

  • Any error triggers the fallback: there is no distinction between a rate limit, an outage and a bad request.
  • A cancelled or timed-out session does not try the remaining models.
  • The step in the session records the model that answered, as provider/model.
  • A tier has one price. A fallback’s calls are priced with the tier’s price, not its own.

Requests-per-minute limits

requests_per_minute spaces the calls of a tier: with a limit of 60, calls to that tier start at least one second apart. A call that arrives early waits its turn. Nothing is rejected.

  • The limit is per tier and is shared by every session of the process.
  • It is kept in memory, per process. With several replicas, each replica applies the limit on its own, so the total rate is the limit times the number of replicas.
  • One wait covers a call and its fallbacks.
  • 0 or no value means no limit.

Budgets

settings/models holds three spend caps, all in USD. A value of 0 or no value turns that cap off.

Key Scope Checked
budgets.per_session_usd One session Before every model call of the session, against the session’s cost so far
budgets.per_day_usd The whole install Before every model call of every session, against the cost of all model calls started in the last 24 hours
budgets.per_month_usd The whole install Before every model call of every session, against the cost of all model calls started since the first of the calendar month, 00:00 UTC

Teams, repositories, skills and people have limits of their own in settings/limits: daily and monthly spend, and how many sessions run at once. See Limits per team and repository and Limits per skill and person.

The caps are checked before a call, so a session can pass a cap by the cost of one call. The daily cap is a rolling 24-hour window, not a calendar day, and it counts every session, including evals run on the server. The monthly cap is checked after the daily one. It does not replace it: a monthly cap alone does not stop one bad day from spending the month, so kojo doctor still asks for a per-session or per-day cap.

When a running session reaches a cap, or a limit of its team, repository or requester:

  1. The model call is refused with budget reached and the amounts.
  2. The session stops working. It is not retried.
  3. kōjō still delivers what exists, with a report that says the budget was reached. A change that was already made goes through the merge policy as a result that did not pass.
  4. The session ends with status failed, and its error is the budget message.

A skill’s limit is the exception: it stops only that skill’s subagent, and the session goes on without it (see Skills).

A session that has not started waits while the daily or monthly cap, or a limit of its team, repository, requester, or the skill it was started for, is spent. It stays queued and is looked at again 10 minutes later, until the spend is back under every limit it counts against. A session that is already running stops at its next model call, as above. The per-session cap never makes a session wait.

Budgets only bound what has a price. kojo doctor fails its budgets check when neither the per-session nor the per-day cap is set, and warns when a tier has no price.

The Helm chart’s default config sets per_session_usd: 10 and per_day_usd: 200, with two tiers that have no price. On a default chart install the caps therefore bound nothing, and kojo doctor warns about it, until you set a price on each tier.

Limits per team and repository

On an install that several teams share, the install-wide caps let one team or one repository spend the whole daily budget, and take every worker. The settings/limits object bounds each team and each repository on its own. Only an admin changes it; its keys, validation and an example are in Runtime config objects.

Limit Key What it bounds
Daily spend per_day_usd The cost of the model calls started in the last 24 hours, a rolling window like the install’s daily cap
Monthly spend per_month_usd The cost of the model calls started since the first of the calendar month, 00:00 UTC
Running sessions max_running How many sessions run at once

Each of them can be set under teams.<name> and under repos.<forge/owner/name>. triggers.<kind>.max_running caps the running sessions of one trigger, the kind of request that started them: eval, schedule, mention and so on. A trigger has no spend limit.

Teams

A team is a team of the rbac object. Its repos key lists the repositories the team owns, and a repository belongs to one team at most. Owning a repository does not narrow the team’s roles: roles hold on every repository.

A session counts against its repository, that repository’s team, and the install, and against its skills and its requester as below. A team’s spend is the spend of the repositories rbac lists for it now, so a repository moved to another team takes its spend of the window with it. A session with no repository, such as a chat request that names none, counts against no team or repository.

  • Evals. A fixture eval (kojo eval <skill>, trigger eval) has no repository: it counts against the install and the eval trigger’s cap. An eval from a repository’s history runs its sessions on that repository, so they count against it and its team. A skill test started from the dashboard counts against the repository it was given, if any.
  • Schedules. Each session a schedule starts runs on one repository and counts against it and its team, like any other session. triggers.schedule.max_running caps scheduled sessions together.

Spend limits

A spend limit works as the install’s daily cap does. Before every model call, the cost of the window is summed from the cost recorded on each model step, by the repository of the step’s session. When a limit the session counts against is spent, the call is refused with budget reached and a message that names the limit, for example team platform spent $50.10 in the last 24h, its daily limit is $50.00, and the session stops as described under Budgets. A session that has not started waits in the queue instead, and is looked at again every 10 minutes.

The install’s daily cap is checked first, then its monthly cap, then the team’s limits, the repository’s, the skill’s and the person’s (see Order of the checks).

Running sessions

max_running is applied when a worker takes a session from the queue. A queued session whose repository, team or trigger already has as many running sessions as its cap is passed over: it stays queued, keeps its place, and starts when one of those sessions ends or waits. A waiting session whose approval was answered, or whose pull request’s checks are due a look, is held the same way. A session whose worker died is resumed whatever the caps say, because it already counts as running. Sessions waiting for an approval or for checks do not count: they hold no worker.

With several replicas, workers take sessions from the queue one at a time while a cap is set, so a cap holds across every replica. A cap at or above the number of workers holds nothing back on one replica; kojo doctor says so.

Changes and visibility

Limits, and the teams of rbac, are read when they are checked. A session does not keep the limits it started with: a lower limit stops a running session at its next model call.

  • The dashboard’s Overview shows the install, each team, repository, skill and person with its spend over 24 hours and over the month, its running sessions, and its limits. A queued session that a limit holds back says which limit in the session list and on its page.
  • GET /api/v1/limits and the MCP tool kojo_limits return the same. GET /api/v1/sessions and GET /api/v1/sessions/{id} add held to a session a limit holds back. See the HTTP API.
  • kojo doctor warns about limits that can never hold anything back: limits of a team that rbac does not define or that owns no repository, of a repository that is not enabled, a cap that is not below this replica’s workers, and a limit that a tighter one is always reached before.
  • kojo limits prints the same from a terminal, and kojo limits set and unset change them (see the CLI).
  • Prometheus counts sessions put back in the queue by a spent budget (kojo_budget_waits_total) and model calls refused by one (kojo_budget_stops_total).

Limits per skill and person

settings/limits also bounds what one skill and one person may spend, and how many sessions one person runs at once. The keys are skills.<name> (per_day_usd, per_month_usd) and people.<key> (per_day_usd, per_month_usd, max_running), with the windows of the table above.

skills:
  fix-bug: {per_day_usd: 20, per_month_usd: 300}
people:
  default: {per_day_usd: 10, max_running: 2}
  alice@example.com: {}
  token:ci-nightly: {per_day_usd: 40, max_running: 4}

Skills

A skill’s spend is the cost of its subagent’s model calls, its judge’s (the goal critic) and its plan’s, in every session and every repository. The orchestrator’s calls belong to no skill. Dry runs (skill tests, evals) and self-improvement sessions neither count against a skill’s limit nor are stopped by it, so testing a skill never spends its budget.

A skill over its limit stops only its own subagent:

  • Before a subagent starts, and before each of its model calls, its skill’s limits are checked. A spent limit refuses the call with budget reached: skill fix-bug spent $20.10 in the last 24h, its daily limit is $20.00.
  • That skill’s result fails, with the limit as its reason, and the orchestrator is told the skill stopped. The session goes on with other skills. A later delegation to the skill in that session is checked again and stops at once while the limit is still spent. A skill found over its limit when its plan would be written is not planned, and stays stopped for the rest of the session.
  • The session’s result then does not pass, so it publishes at most a draft pull request of the changes that exist, and ends failed with the stop as its reason.

A session whose request names a skill (kojo run --skill, a schedule’s skill, a repository’s auto skill) waits in the queue while that skill is spent, as it would for a team. A session that names no skill does not wait: its skill is not known until the orchestrator delegates.

Skills have no max_running, and settings/limits refuses one: most sessions are not known to belong to a skill when a worker takes them from the queue, so a claim cannot count them.

People

A session counts against the person who asked for it:

Request Person
A mention on an issue or pull request Its author
A chat message Its author
A run from the dashboard, the CLI, the API or MCP Who signed in, or the API token (token:<name>)
A campaign’s sessions The campaign’s creator
A ticket in a tracker Who assigned, labelled or mentioned it

Events nobody asked for (a new issue, a new pull request, a push, a failed check), schedules, alerts, feedback and self-improvement sessions count against no one. The person is worked out when the request is accepted and recorded on the session.

A key is a person as kōjō records them, in lower case: an email (alice@example.com, without email:), or <surface>:<id> when the surface gives no email (github:alice, slack:u02abcdef, token:ci-nightly). A login that settings/memory.identities links to an email is recorded as that email, so its entry is the email’s. Changing identities later does not move sessions or spend already recorded under the old key.

people.default applies to everyone without an entry of their own. A person’s entry replaces it as a whole: alice@example.com: {} has no limit at all, while an entry that sets only per_day_usd leaves that person’s month and running sessions unbounded. Without default, a person without an entry has no limit.

A person’s cap on running sessions is applied when a worker takes a session from the queue, under the same lock as the other caps, so it holds across replicas.

What a person spends is private. A held session, a stopped session and a pull request description say its requester's daily limit was reached or its requester's running-session limit, never the person or the amounts. GET /api/v1/limits lists people only to the operator role and up.

Order of the checks

Before every model call, and before a queued session starts, the limits a session counts against are checked in this order. The first spent one is the one named.

flowchart LR
  A[Install, last 24 hours] --> B[Install, this month]
  B --> C[Team]
  C --> D[Repository]
  D --> E[Skill]
  E --> F[Person]

Each of team, repository, skill and person is checked for the day, then the month. The skill is the one whose subagent, judge or plan makes the call, or for a queued session the skill it was started for.

Seeing and changing them

  • The dashboard’s Overview lists the install, each team, repository, skill and person with its spend and limits; people only for operators. /settings/limits edits them.
  • GET /api/v1/limits and the MCP tool kojo_limits return the same, with skills, people, people_default and install.per_month_usd (see the HTTP API).
  • kojo limits, kojo limits set and kojo limits unset read and change them from a terminal (see the CLI).
  • kojo doctor warns about a skill limit no scope resolves, a person key whose namespace is not a surface of the install, a login that identities link to an email, a person allowed more than people.default, and an install whose daily cap is not below its monthly cap.
  • kojo_budget_waits_total and kojo_budget_stops_total count with limit="skill" and limit="person".
The Limits settings page, scrolled to the Skills panel with daily and monthly limits for build-feature and fix-bug, and the People panel with an Everyone else row of 10 dollars a day and 2 running sessions and an entry for ana@acme.test, next to the history of revisions.
Limits per skill and per person under Settings, Limits.

Prices and cost

kōjō ships no price table. A price is configured per tier, in USD per million tokens, and you keep it in step with your provider’s price list.

The cost of a call is:

cost_usd = (tokens_in * input_per_mtok + tokens_out * output_per_mtok) / 1000000

The token counts are the ones the provider reports for the call. A tier without a price costs 0 USD per call: its calls are recorded with their tokens, add nothing to the session’s cost and are not capped by the budgets. For a local model, set a notional price if you want the budgets to limit token use.

Where cost shows up:

Place What
Each model step of a session Model that answered, tokens in, tokens out, cost
The session Total cost and tokens, in kojo sessions list, kojo sessions show and the dashboard
kojo run Cost and tokens on the last line, when the cost is above 0
Dashboard overview Cost of the last 24 hours against the daily budget, and of the last 7 days; each team’s and repository’s cost over 24 hours and over the month against its limits
kojo eval report Cost per case and per run
Audit log cost_usd in the session.end entry
Prometheus kojo_model_cost_usd_total (labels tier, model) and kojo_model_tokens_total (labels tier, model, direction)

See Prometheus metrics for the metrics and Observability for session replay.

Embedder

models.embedder names the embedding model of team memory, as a provider and a model. Without one, and whenever an embedding call fails, memory search uses Postgres full-text search. See Skills for memory.

Provider Embedding models
googleai, vertexai gemini-embedding-2; gemini-embedding-001
openai text-embedding-3-large, text-embedding-3-small
azure Your deployment of text-embedding-3-large or text-embedding-3-small, by its deployment name
bedrock Amazon Titan Text Embeddings V2 (amazon.titan-embed-text-v2:0) and Cohere Embed v3 (cohere.embed-english-v3, cohere.embed-multilingual-v3): the embedding models the Bedrock plugin supports

openrouter and ollama have no embedder in kōjō: their Genkit plugins register none by name, so an embedder on either fails and memory search uses full-text search.

models:
  embedder:
    provider: googleai
    model: gemini-embedding-2

This fragment goes inside the models block of kojo.yaml.

The replay provider

The replay provider answers model calls from recorded responses. It needs no network and no API key. The dev stacks, the end-to-end tests and the skill evals in CI run on it. See Recordings and Evals.

Replay is on when either of these is true:

  • models.recordings names a directory and KOJO_LIVE_MODELS is not 1.
  • The tiers use the mock provider. Then models.recordings is required, every tier must be mock, and KOJO_LIVE_MODELS=1 has no effect.

kōjō logs a warning at start when it replays, and kojo doctor warns that no real model is called.

Recordings

models.recordings is a directory. Every .yaml and .yml file under it, at any depth, is a list of recordings:

- purpose: subagent:fix-bug
  match: "lib/pages.sh"
  turns:
    - tool_calls:
        - name: read_file
          input:
            path: lib/pages.sh
    - text: "The page count is an integer division, which rounds down."
- purpose: judge:fix-bug
  match: "lib/pages.sh"
  turns:
    - json:
        pass: true
        unmet: []
        feedback: ""
Key Meaning
purpose Who is calling: orchestrator, subagent:<skill>, judge:<skill>, risk, schedule. A trailing * matches any suffix, as in judge:*. Required
match A substring that must appear in the system prompt or the user messages. Recordings with a match are tried first
turns The replies, in order. At least one
turns[].text Text of the reply
turns[].tool_calls Tool calls of the reply: name and input
turns[].json A structured reply, such as a judge’s verdict
turns[].tokens_in, turns[].tokens_out Reported token counts. Default 100 and 20
repeat_last Answer with the last turn once the turns are used up, instead of failing

The reply given is the turn whose index equals the number of model messages already in the conversation. Replay keeps no state, so a session resumed from a checkpoint gets the same answers.

A call with no matching recording fails with mock model: no recording for purpose "<purpose>", and the session is not retried. The doctor purpose needs no recording: it is always answered with OK.

The repository ships two sets of recordings under testdata/recordings: evals/, for the eval fixtures of every built-in skill, one file per skill (such as fix-bug.yaml), and dev/demo.yaml, the scripted conversations of the local dev stack.

A tier’s price still applies in replay, to the recorded token counts.

Dev stack setup

The compose dev stack (deploy/compose/kojo.dev.yaml) keeps real tiers and adds a recordings directory:

models:
  gateway: embedded
  recordings: "${KOJO_DEV_RECORDINGS:-/recordings/dev}"
  tiers:
    fast:
      provider: anthropic
      model: claude-haiku-5-5
    strong:
      provider: anthropic
      model: claude-opus-5-5
  budgets:
    per_session_usd: 5
    per_day_usd: 50

Because the tiers are real, KOJO_LIVE_MODELS=1 switches the same file to the live providers. The chart’s CI values use the other form, with mock tiers:

models:
  recordings: /var/lib/kojo
  tiers:
    fast:
      provider: mock
      model: mock-fast
    strong:
      provider: mock
      model: mock-strong

Both fragments go inside a complete kojo.yaml.

Environment variables

Variable Effect
KOJO_LIVE_MODELS=1 Ignore models.recordings and call the configured gateway. Needs the providers’ keys or credentials. No effect with mock tiers
KOJO_RECORD=1 With KOJO_LIVE_MODELS=1 and models.recordings set: write every live answer as a recording

Recorded answers go to <recordings>/recorded/, one file per session and purpose, named <session>_<purpose>.yaml with : replaced by -. A file is rewritten after each turn. A recorded file has a purpose and turns and no match: add one before you keep it. The recordings directory is read recursively, so files left in recorded/ are replayed on the next start without KOJO_LIVE_MODELS=1.

make record does this for the evals. It runs them against the live model with evals/kojo.record.yaml, which is the eval config with real tiers and models.recordings: out/recordings/evals:

ANTHROPIC_API_KEY=<your key> make record
ANTHROPIC_API_KEY=<your key> make record SKILL=fix-bug

It needs ANTHROPIC_API_KEY, and it costs what the calls cost. The answers land in out/recordings/evals/recorded/, which nothing replays. Read them, check that no key or token is in one, then move the ones you keep into testdata/recordings/evals/, which is what make eval and CI replay.

Checking the setup

Validate the file, then check that every tier answers:

kojo config validate -f kojo.yaml
kojo doctor -f kojo.yaml

kojo config validate checks the structure: required tiers, provider names, the gateway URL, the provider settings (a project ID, a location, a region, https endpoints), non-negative budgets. It does not contact a provider. kojo doctor, with the embedded gateway:

  • checks each provider that a tier, a fallback or the embedder uses, as model provider <name>: its credentials resolve, and the first model of it in tier order answers one prompt (the embedder, for a provider only the embedder uses). The detail says where the credentials came from, such as AWS credentials from WebIdentityCredentials, region us-east-1, never what they are. A provider that kojo.yaml configures and nothing uses gets the credential check only, and a failure there is a warning;
  • sends one prompt to each tier, with its fallbacks, as model tier <name>.

Each check has a timeout of 60 seconds. Doctor also reports the budgets and any tier without a price. See the CLI reference.

Scroll to move. + - zoom, 0 fit, Esc close.100%