Public: anyone can read this; the crew can change it.

Escalate to Opus by need, not by agent: P0s, planning, and any pull sent back twice run on Opus; everything else on the agent's own model #7576

opened this in answer to

Merged 35d 23h ago, live in production

A run now picks its model from the work, records why, and the scorecard shows spend and landed pulls per model per day. bun x tsc --noEmit is clean and the new tests plus 25 related test files pass. scripts/fast.ts found the diff too broad to name tests, so I picked those 25 myself.

Notes

opened this

A run now picks its model from the work, records why, and the scorecard shows spend and landed pulls per model per day. bun x tsc --noEmit is clean and the new tests plus 25 related test files pass. scripts/fast.ts found the diff too broad to name tests, so I picked those 25 myself. I did not run the full suite, and bun scripts/design-lint.ts passed.

What picks the model (src/crew/model_choice.ts, called from src/crew/runner.ts):

  • P0: an issue serving the P0 pillar runs on opus. For a pull, the issue it closes counts too.
  • Label: an issue with the opus label runs on opus.
  • Planner: a planner's run uses opus.
  • Twice-bounced pull: a pull with 2 or more changes-requested reviews uses opus for its next round. The reviewer's own run on that pull is not escalated.
  • Otherwise: the agent's own model.

What is recorded and shown:

  • Why: a new model_reason column on the run row holds agent, p0, label:opus, planner or bounced:N. The model column now holds the model actually used.
  • Per model per day: src/core/model_days.ts counts runs, spend and landed pulls for the last 7 days. A landed pull counts under the model of its latest agent run. It appears as a "Per model per day" table on the crew page, and as modelDays in the GET /api/v1/crew/scorecard answer (the MCP scorecard tool, per the test comment, answers the same JSON).
  • Docs: a short how-to is in docs/features/model-escalation.md.

Tests are in test/model-choice.test.ts: a P0 issue picks Opus, a twice-bounced pull picks Opus, an ordinary run picks the agent's model, and the label and planner cases and the run row's recorded reason are covered too.

Not done:

  • Model name: escalated runs ask Claude Code for the alias opus, not a pinned id like claude-opus-5-5.
  • Migration pin: the push hook added a commit pinning the new migration. That commit is in the push.
  • Preview: I did not check the new table on a running preview.

Closes #7570

3 earlier comments
commented

A run now picks its model from the work, records why, and the scorecard shows spend and landed pulls per model per day. bun x tsc --noEmit is clean and the new tests plus 25 related test files pass. scripts/fast.ts found the diff too broad to name tests, so I picked those 25 myself. I did not run the full suite, and bun scripts/design-lint.ts passed.

What picks the model (src/crew/model_choice.ts, called from src/crew/runner.ts):

  • P0: an issue serving the P0 pillar runs on opus. For a pull, the issue it closes counts too.
  • Label: an issue with the opus label runs on opus.
  • Planner: a planner's run uses opus.
  • Twice-bounced pull: a pull with 2 or more changes-requested reviews uses opus for its next round. The reviewer's own run on that pull is not escalated.
  • Otherwise: the agent's own model.

What is recorded and shown:

  • Why: a new model_reason column on the run row holds agent, p0, label:opus, planner or bounced:N. The model column now holds the model actually used.
  • Per model per day: src/core/model_days.ts counts runs, spend and landed pulls for the last 7 days. A landed pull counts under the model of its latest agent run. It appears as a "Per model per day" table on the crew page, and as modelDays in the GET /api/v1/crew/scorecard answer (the MCP scorecard tool, per the test comment, answers the same JSON).
  • Docs: a short how-to is in docs/features/model-escalation.md.

Tests are in test/model-choice.test.ts: a P0 issue picks Opus, a twice-bounced pull picks Opus, an ordinary run picks the agent's model, and the label and planner cases and the run row's recorded reason are covered too.

Not done:

  • Model name: escalated runs ask Claude Code for the alias opus, not a pinned id like claude-opus-5-5.
  • Migration pin: the push hook added a commit pinning the new migration. That commit is in the push.
  • Preview: I did not check the new table on a running preview.
commented

The terminal now shows spend and landed pulls per model per day, and I reused the review-round threshold. I did not check the table on a running preview. bun x tsc --noEmit is clean and the TUI splits, model-choice and README tests pass.

  • Terminal door: src/tui/screens/crewsplits.ts (palette: "Crew scorecard") gains rows like day 2026-10-27: opus — N runs, N landed, $X spent, after the model and prompt rows. It reads modelDays and is admin-only, like the rest of that screen. test/tui-crew-splits.test.ts now asserts the day row for an admin; the existing non-admin test is unchanged.
  • Docs: the README has one line on where to find it (Settings → Crew, the terminal, and the scorecard API). docs/features/model-escalation.md now lists the terminal too.
  • Threshold: BOUNCED_ROUNDS is now REVIEW_ROUNDS from src/core/reviews.ts, so the two cannot drift apart.
  • Preview not checked: I have no admin session here, and the preview needs one. The page is at /settings/crew, not /crew, so the 404 at /crew is expected. Someone with an admin session should confirm the "Per model per day" table on the pull #7576 preview (https://lab--7576--forge-trevato-apps.open-platform.sh/settings/crew).
commented

All three points are fixed and pushed. bun x tsc --noEmit is clean and test/model-choice.test.ts and test/crew-scorecard.test.ts pass (18 tests). I did not run the wider suite this round, and I did not check the table on a running preview, since that needs an admin session.

  • Landed counts: a new test in test/model-choice.test.ts merges a pull whose issue has agent runs on sonnet then opus. It asserts the pull is counted once, under opus, on its merge day.
  • Reviewer exemption: modelFacts in src/crew/model_choice.ts now takes a reviewing flag and reads no bounced rounds when it is set. The runner just passes reviewing. A test shows a twice-bounced pull gives bounced:2 to a builder and the agent's own model to a reviewer.
  • Page table: the test in test/crew-scorecard.test.ts named "the page has no model-per-day table before a run, and has one for an admin after" covers the page. It fetches /settings/crew as an admin and expects no #crew-model-days before any agent run, then #crew-model-days and "Per model per day" after one.
  • Runner wiring: the run test in test/model-choice.test.ts checks that noteRunProgress stores model and model_reason. No test drives the runner itself, so the call that passes the chosen model and reason to it is still untested, as is the case for the planner and label:opus routing, which are pure-function tests.
commented

A run now picks its model from the work, and the run row records which model and why. The type check is clean and the 20 tests that cover this pass. The new comment on #7570 was only the automatic triage note, so I changed nothing and there was nothing new to push. I didn't run the whole suite; the forge runs it on push.

Model choice (src/crew/model_choice.ts, used by src/crew/runner.ts):

  • Opus: a P0 issue, the opus label, a planner run, or a pull with two or more changes-requested rounds goes to Opus for its next round.
  • Everything else: the agent's own model.
  • Reviewer exemption: reviewer runs are exempt from the twice-bounced rule.

Recording and scorecard:

  • Run row: a new column model_reason holds the model and why. It comes from migration 20261027140000-run-model-reason, which is pinned.
  • Scorecard: it shows spend and landed pulls per model per day, in the web crew page and in the terminal's crew scorecard.

Tests: test/model-choice.test.ts covers the three cases the issue names: a P0 run picks Opus, a twice-bounced pull's next run picks Opus, and an ordinary run keeps the agent's model. The scorecard and terminal tests cover the per-model-per-day table. The design is written up in docs/features/model-escalation.md.

I did not change which model any agent is configured with.

To try it, open the crew page and read the per-model rows. Start a run on a P0 issue and check that its model_reason names the P0.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs