koi
Documentation / architecture

Model tiers

Yokai does not pin one model for the whole run. Each phase gets a capability tier, each tier lists agent and model candidates in order, and each turn takes the first candidate that opens.

Why tiers

Renaming a field and redesigning a state machine do not need the same model. A tier describes how much capability a phase needs. Your settings map each tier to concrete agents and models. When a provider changes its lineup, you edit one list in .koi/yokai.yml instead of every phase.

Junji alone does not use tiers. When you run /junji next, the phase runs with whatever agent and model you have open.

The pieces

  • Tier: one of four bands, low, medium, high or ultra. medium is the default.
  • Phase assessment: the tier chosen for one phase, with a one-line reason, approved by a human. On a JSON board it sits on the card as "yokai": {"model-tier": "high", "reason": "..."}.
  • Candidate: one agent with an optional model, effort and speed, such as {agent: claude, model: opus}. A tier holds an ordered list of candidates; the first is preferred.
  • Role: the kind of turn. Plan, coder, judge and seal use the phase tier unless you lift them. Repair, fix and triage (Diagnose) use ultra unless you set otherwise.

A tier is a band, not a model. Yokai treats model IDs as opaque strings that the agent supplies; it never interprets them.

How a turn picks its candidate

From phase tier to the agent that answers
Tier resolution and the candidate walk The phase tier from the board card selects a tier band. A role override in yokai.yml can lift the band for one kind of turn. The band lists candidates in order. The turn opens with the first candidate; if that candidate is unreachable, limited or unstable, Yokai records a skip and tries the second. Role override roles.<role>.tier Phase tier Tier band: high 1st candidate on skip 2nd candidate
  1. If you launched with --agent, --model or --effort, Yokai builds one candidate from those flags and skips the rest of this list.
  2. Otherwise it finds the role's tier: roles.<role>.tier if set, else the phase tier for plan, coder, judge and seal, else ultra for repair, fix and triage.
  3. It walks that tier's candidate list when the turn opens. If a candidate cannot open a session because it is unreachable, rate limited or unstable, Yokai writes a skip row to ledger.jsonl and tries the next one for the same turn.
  4. A skipped candidate is not tried again until tiers.retry_after_secs passes (3600 seconds by default). If every candidate is skipped, the run halts.

A red test or a Build that does not converge is the work failing, not a reason to switch candidates. A missing effort or speed option is a notice, not a skip. An agent that dies mid-turn is an interrupt; the turn can reattach.

Example settings

# .koi/yokai.yml
model_mode: tiers
tiers:
  low:
    - agent: claude
      model: haiku
  medium:
    - agent: claude
      model: sonnet
    - agent: codex          # fallback if Claude is unavailable
  high:
    - agent: claude
      model: opus
  ultra:
    - agent: claude
      model: opus
      effort: max
roles:
  judge:
    tier: high

With this file, a medium phase codes with Sonnet and is reviewed by Opus. If the Claude adapter cannot open a session, the coder turn falls back to Codex with its default model.

model_mode: single means you chose One model in setup: the same agent and model fill all four bands.

Who chooses the tier

Yokai proposes a tier and a reason for each unfinished phase during setup, or the optional /yokai assess helper does it from chat. You approve with Approve and continue. A saved, complete choice is authoritative: Yokai does not ask again at the next launch or check it against a hash. Reconsider it yourself when a phase's scope changes. Headless startup stops if a phase has no tier or no reason.

A rough guide: low for mechanical edits with clear checks, medium for bounded work with good tests, high for cross-module changes and migrations, ultra for tightly coupled work where another failed attempt is expensive. Agents and models suggests concrete models.

What can go wrong

  • missing or incomplete phase assessment. A phase has no model-tier or no reason. Open yokai setup and approve the proposals.
  • tiers.medium must list at least one candidate. A band is an empty list. Add a candidate or rerun setup.
  • Every candidate skipped. The agent is logged out or out of quota. Fix the login, or wait for retry_after_secs.
  • A notice like effort ... exposes no ... selection. The turn still runs, but the candidate sets effort on an agent that has no reasoning selector, often Cursor. Remove effort from that candidate.