Model and Effort per Phase

Contents
  1. The Phase agent Key
  2. The agents Block
  3. Shipped Tiers
  4. Escalation on Stall
  5. Escalation After Rejections
  6. Where the Settings Show
  7. Status
  8. Enforcement
  9. History
  10. Picking a Tier
  11. See Also

Documentation › Model and effort per phase

A project can choose which model and reasoning effort each delegated phase’s subagent uses. Easy work then runs on cheaper models and hard work gets a stronger one.

Only delegated phases can be steered. Hooks cannot change the main session’s model. In a delegated phase the main session only starts one subagent, and the subagent does the work, so its model can be chosen. In feature mode every shipped phase is delegated; in single mode only phases with delegate: true are.

With no tier chosen and no agent key, nothing is required and specloop behaves as before.

The Phase agent Key

Any delegated phase in phases, feature.planPhases or feature.stepPhases may have an agent key:

"implement": { "delegate": true, "agent": { "model": "sonnet", "effort": "medium" } }
Key Values Meaning
model a name matching ^[A-Za-z0-9][A-Za-z0-9._\[\]-]*$, such as haiku, sonnet, opus Passed to the Agent tool as it is, so a new alias needs no specloop release.
effort low, medium, high, xhigh, max Reasoning effort of the subagent.

Either key may be "inherit" or left out. That sets no requirement. An agent key on a phase that is not delegated is an error, because the main session’s model cannot be set.

The agents Block

Key Default Meaning
agents.tier null Name of the tier the run uses. null means no tier.
agents.enforce true Deny a main-session Agent call that does not carry the phase’s settings (see Enforcement).
agents.maxDenials 2 Denials per attempt before the check gives up and allows the call.
agents.escalateOnStall true Move to the tier’s escalateTo instead of stalling on maxIterations (see Escalation on stall).
agents.escalateAfterRejects 2 Rejections of a step that move the run to the next tier (see Escalation after rejections). 0 turns it off.
agents.tiers light, standard, heavy Named tiers. A tier has escalateTo (another tier) and phases, which maps a phase name to {model, effort}.

The run’s tier is state.tier when set, else agents.tier. The effective settings of a phase are its agent key, with each field replaced by the run tier’s entry for that phase name when the entry sets it. A tier entry matches by phase name in the active graph, so implement applies to the single-mode phase and to the step phase alike. An entry for a phase that does not exist or is not delegated is ignored.

An invalid agents block or agent key makes /sl-go refuse to start and print the errors; a hook that meets one requires nothing.

Shipped Tiers

Tier feature-plan implement review escalateTo
light sonnet, medium haiku, high sonnet, high standard
standard sonnet, high sonnet, medium sonnet, high heavy
heavy opus, high opus, high opus, xhigh none

Review never runs below sonnet. A cheap implementer, a strong reviewer and the quality gates are where the savings are safe.

Escalation on Stall

When a run reaches maxIterations, the engine stalls it. With agents.escalateOnStall: true, a run whose tier has an escalateTo moves to that tier instead:

  • state.tier becomes the target tier, the iteration counter is 0, and a new attempt starts. The working tree is untouched (no stash, reset or checkout).
  • The run restarts at the phase it stalled in. In a feature-mode step it restarts at feature.stepInitialPhase, as a replan does.
  • The history gets an escalated entry with from, to and reason.
  • The Stop message starts with a line that names both tiers, for example: Escalated from tier light to tier standard after 15 iterations in phase 'implement'. The model cost changes. The new phase prompt follows.

The new tier lasts for the rest of the run. A failing block quality gate uses an iteration like any failed check, so it can lead to escalation. A broken gate pauses the run and never escalates. A run with no tier, with escalateOnStall: false, or on a tier without escalateTo (such as heavy) stalls as before.

Escalation After Rejections

A run can also escalate when reviews keep asking for changes. The engine counts the rejections of each step in state.rejectCounts (key: the step id, or single in single mode). When the count reaches agents.escalateAfterRejects on a tier that has an escalateTo, the run escalates instead of going back after the rejection:

  • The review is archived as usual, the counter of that step resets to 0, and the tier, the iteration counter, the attempt and the history change as in Escalation on stall (the reason is N rejections).
  • A feature-mode step restarts at feature.stepInitialPhase. Single mode restarts at the onReject phase.
  • The Stop message names both tiers, for example: Escalated from tier light to tier standard after 2 rejections in phase 'review'. The model cost changes.

Below the threshold a rejection works as before. A rejection of another step does not add to the count. escalateAfterRejects: 0, a run with no tier, or a tier without escalateTo leaves rejections as before. escalateOnStall does not affect rejections.

Where the Settings Show

The orchestrator preamble (phases/delegate.md) has an {agent_settings} placeholder. It becomes one sentence, for example Pass `model: "haiku"` and `effort: "high"` to the Agent tool., with only the fields that are set, and nothing when none is. An override of delegate.md without the placeholder keeps working.

The context header shows the same settings and the run tier after the phase name: phase=implement (haiku, effort high, tier light). It shows (tier light) when the tier sets nothing for the phase, and it is unchanged when no setting and no tier applies.

Status

/sl-status appends lines when a tier is set or a phase has an agent key, and prints nothing extra otherwise:

  • agents: tier light (- when the run has no tier).
  • agents: escalated from tier light to tier standard (2 rejections), from the latest escalated history entry.
  • agent phase implement: model haiku, effort high per delegated phase of the graph in use (agent plan <phase> and agent step <phase> in feature mode); - when nothing is set.
  • agents: unused tier entry light.ghost ... for a tier entry that names a phase that does not exist or is not delegated.
  • agents: settings not applied in attempt ... after enforcement gave up.

An invalid agents block prints agents: invalid, settings are not applied and each validation error; the command does not fail.

Enforcement

With agents.enforce: true, PreToolUse checks every Agent call (and Task, the name older Claude Code versions use) that the owner’s main session makes while the run is active in a delegated phase with settings. A call whose model differs from the required one (names compare case-insensitively), whose effort differs, or that leaves a required one out is denied. The reason names the subagent_type, model and effort to pass, so Claude can retry.

Calls from inside a subagent (hook input with agent_id) are never checked. agents.enforce: false keeps the instruction in the preamble and drops the check. An invalid agents block requires nothing and never fails the hook.

Each denial is counted per attempt in agentDenials in state.json. When the count in an attempt reaches agents.maxDenials, the next call is allowed, state.agentSettings records the attempt and the reason, and the history gets an entry with agentSettings: "not applied". Later calls in that attempt are allowed without more denials. The phase’s Stop message says that the settings were not applied and that the Claude Code version may lack the parameter. Enforcement starts again with the next attempt. Enforcement under claude --agent specloop-orchestrator is unverified; see The orchestrator agent route.

History

Each gate entry in state.history (phase, result, iter) in a delegated phase with settings also has model and effort, only those set. They are the settings in force when the gate ran, before any escalation. Entries of other phases, and of runs with no settings, have neither field.

Picking a Tier

For a project, set the tier in .claude/specloop/config.json:

{ "agents": { "tier": "standard" } }

For yourself, set it in .claude/specloop/config.local.json, which wins over config.json (see Personal configuration):

{ "agents": { "tier": "light" } }

Both files merge over the defaults, so one phase of one tier can change on its own. Set a tier to null to remove it.

See Also

View this page on GitHub