Skip to content
Greenware
Esc
↑↓navigate↵open⌘Jpreview
On this page

Model and effort tuning

Spend model tokens where judgment decides the play (the contract, the plan, the independent check) and save them everywhere else. The tier knobs, the per-stage models and gw models added in v0.8.0, and how to measure what a play cost.

Verification: verified on the twin for v0.7.0’s knobs, and on main after PR #17 merged for the v0.8.0 section (details at the bottom).

A play has two bills. Clay credits pay for data and actions (maxCreditsPerPlay, the plan’s cost estimate, Gate A’s budget). Model tokens pay for the stage agents: every stage runs Claude Code under your own login. This page is about the second bill. The first is in each play recipe’s “Cost levers”.

Where the tokens go

Each stage runs on a tier. A stage key for effort wins over its tier:

Stage Tier What it decides Recommendation
Decompose strong How your idea is read, and which blueprint Default. A misread wastes everything after it, but you correct it with gw answer … reading
Clarify strong What to ask you, and what to answer from your files Default
Research mid Requirements from standards, decisions, workspace facts and the web The cheapest place to save: low effort
Spec + Contract strong The pass/fail contract Spend here. A weak contract makes Verify meaningless
Plan strong The graph, the cost, the standards mapping Spend here
Build mid Clay CLI calls, read back after every edit Default. Mostly mechanical, and the engine validates the graph
Verify mid The independent check on real records and holdouts Keep at medium or above. It’s the one agent that grades the others
Audit mid A last review of the snapshot Default
Document mid deliverables/README.md Cheap: low effort

Outside the pipeline: gw client research (client onboarding) runs on the strong model, and gw client functions (the function shortlist) and the Herdr maestro run on the mid model.

The recommendations are judgment calls, not measurements. Measure your own (below).

The tier knobs (every release)

models:
  strong: opus     # decompose, clarify, spec, plan; also gw client research
  mid: sonnet      # research, build, verify, audit, document; also the shortlist and the maestro
agents:
  effort:          # Claude Code --effort: low | medium | high | xhigh | max
    strong: medium
    mid: medium
    plan: high     # a stage key wins over its tier
    verify: high
  • models.strong and models.mid are passed to claude --model. Aliases like opus and sonnet work, as do full model ids.
  • agents.effort takes a tier or a stage id. Lower effort means less thinking per turn: faster and cheaper.
  • One-off model overrides: gw client research <id> --model <m> and gw client functions <id> --model <m> take a model for that run only.
  • Fewer retries: maxStageAttempts (default 2: one retry with the validation errors, then the play stops for you) and maxBuildLoops (default 3). Each retry or loop is a full stage run.
  • Fewer questions: maxQuestionsPerRound caps Clarify’s open questions. Past the cap, questions.json fails validation, and Clarify has to assume the rest with defaults. maxClarifyRounds is in the schema, but the engine doesn’t read it yet.

Three v0.7.0 gotchas, all fixed in v0.8.0:

  1. A typo in agents.effort is silently ignored. verfy: high loads fine and changes nothing. Check spelling against the stage ids above.
  2. effort.research also sets client research. gw client research reads effort.research, then effort.strong, so tuning the Research stage tunes onboarding too.
  3. The maestro gets no --effort. It runs on models.mid with Claude Code’s own default.

Three starting profiles are in examples/factory/:

File For What it changes
cheap.yaml SMB clients, exploratory plays Sonnet on both tiers, low effort on mid stages except Verify, 3 questions a round, 2 build loops, 150-credit ceiling
careful.yaml Enterprise clients, plays that send or write Opus on strong, high effort on Spec, Plan, Verify and Audit, 300-credit ceiling
agency.yaml Many clients in Herdr High effort on Plan, a named Herdr session, 250-credit ceiling

Copy one over your factory.yaml and keep your own runner and clay lines. These settings are per factory, so clients that need different ones belong in different factories (One factory, many clients).

Per-stage models and gw models (v0.8.0)

New in v0.8.0 (PR #17). On v0.7.0, any models key other than strong and mid is silently dropped; run gw upgrade.

models and agents.effort accept the same keys: a tier (strong, mid), any stage that runs an agent (decompose, clarify, research, spec, plan, build, verify, audit, document), or one of the three agents outside the pipeline: onboarding (gw client research), shortlist (gw client functions) and maestro (the Herdr play pane). An agent’s own key wins over its tier’s.

models:
  strong: opus
  mid: sonnet
  verify: haiku        # just Verify on a cheaper model
  document: haiku
agents:
  effort:
    strong: medium
    mid: medium
    plan: high
    onboarding: high   # client research, separate from the Research stage at last

gw models shows what every agent runs with and which key set it, before anything runs. Here it is for examples/factory/cheap.yaml with its document: haiku line uncommented:

agent       tier    model   from                  effort  from
verify      mid     sonnet  models.mid (tier)     medium  agents.effort.verify
document    mid     haiku   models.document       low     agents.effort.mid (tier)
…

Typos now fail loudly. Every gw command that loads the factory exits 1:

gw: factory.yaml in ~/factory is invalid: agents.effort.verfy: unknown key "verfy"; use strong or mid,
    a stage (decompose, clarify, research, spec, plan, build, verify, audit, document) or onboarding, shortlist, maestro

v0.8.0 also prints the failing path for any invalid factory.yaml, where v0.7.0 printed only invalid: [. Gate and Publish keys (gate_a, gate_b, publish) are rejected because they run no agent. effort.research keeps setting client research until you set onboarding, and gw models marks that row (legacy; set onboarding).

Measure what a play cost

With the headless runner, each stage’s agent.result event carries Claude Code’s reported cost. Sum it per stage from the play’s event log:

jq -s 'map(select(.type == "agent.result"))
       | group_by(.stage)
       | map({stage: .[0].stage, runs: length, usd: (map(.data.costUsd // 0) | add)})' \
   ~/factory/plays/acme/lookalikes-01/events.jsonl

runs counts attempts, so retries and build loops show up. If Build has 4 runs and Verify 4, the problem is usually the contract (Spec), not Build’s effort. Spend more at Spec or Plan, not at Build.

A tuning loop that works:

  1. Run a play on the defaults and record the per-stage cost and runs.
  2. Lower one stage (Research or Document first).
  3. Run a comparable play. If that stage’s runs went up (validation failures, more loops), the saving was false: put it back.
  4. Never lower Verify below medium to save money. Its whole value is being right when the builder is wrong.

Failure modes

What you see What it means What to do
A stage tuned to low keeps going flawed Not enough thinking to produce a valid artifact Put it back to its tier; check runs in the cost query
Build loops 3 times on the same assertion The contract or plan is the problem, not Build Raise effort on Spec and Plan, or reopen Gate A with a ruling
A setting has no effect (v0.7.0) A typo, or a per-stage models key that v0.7.0 drops Spelling; per-stage models need v0.8.0
Onboarding got slower after you tuned Research (v0.7.0) effort.research also sets client research Expected in v0.7.0; v0.8.0 adds onboarding
costUsd missing in the events The scripted runner (twin) reports none; the figure comes from claude -p’s result Measure with the headless runner

Verification

Verified on the twin (v0.7.0): all three examples/factory/*.yaml load with v0.7.0’s loadFactory and give the models, effort, ceilings and Herdr settings described; an agents.effort.verfy typo loaded silently into the effort map; a models.document key was dropped. The cost query ran on a twin play’s events.jsonl: it grouped agent.result per stage, with usd 0, because the scripted runner reports no cost. The tier per stage is from src/core/pipeline.ts, the effort resolution from src/core/engine.ts, and the client research, shortlist and maestro behavior from src/core/onboard.ts, src/core/functions.ts and src/herdr/maestro.ts.

Verified against PR #17 head 918a69e (a git archive of the branch, run on a twin factory): gw models for each example file, the document: haiku output above, and the verfy error with exit 1.

Verified on main after PR #17 merged (twin factory): examples/factory/cheap.yaml with document: haiku uncommented gives the gw models rows above (verify agents.effort.verify, document haiku models.document), and a models.verfy key exits 1 with the unknown-key message.

Not run: real headless stages, so no real costUsd and no measured savings.

Was this page helpful?