Repository navigation
Closed
Labels
bugSomething isn't working
Description
Tier: mechanical
Problem
resolvedModel is the first key of the driver's modelUsage map (phase-executor.ts:1807-1809, #975). The comment there assumes that "first key is the primary model dispatched". That stopped being true: Claude Code phases now make a small Haiku side call before the first main-model response, so claude-haiku-4-5-20251001 comes first in modelUsage.
Evidence from this repo's .sequant/metrics.json:
- Every
phasePolicies.<phase>.resolvedModelrecorded from 2026-09-20 onward isclaude-haiku-4-5-20251001, across runs whose policy wassonnetoropus. Every run through 2026-09-19 records the real model. The change happened between 2026-09-19T07:23Z and 2026-09-20T13:10Z. - The
phaseUsagerows for those same executions show what actually ran. Haiku costs about $0.000–0.001 per phase. The Sonnet or Opus row next to it carries the real cost.
phaseUsage itself is correct, because normalizeModelUsage keeps every key. Only the single-model summary is wrong.
Blast radius
metrics.phasePolicies.<phase>.resolvedModel(feat(config): model roles — semantic indirection between phase policy/ladders and concrete model strings #975). This is the field feat(config): model roles — semantic indirection between phase policy/ladders and concrete model strings #975 added to make comparisons over time survive alias moves.- The run log's per-phase
model(feat(logs): run log records each phase's model and the sequant version #1198 AC-1,batch-executor.ts, the threemodel: …resolvedModelsites). - The metrics' top-level
model(feat(logs): run log records each phase's model and the sequant version #1198 AC-3,run-orchestrator.ts:2056,.find(Boolean)over resolved phase models). The locally linked dist predates feat(logs): run log records each phase's model and the sequant version #1198, so recent records still readopus. The next release flips this field to Haiku for every run.
Any grouping of runs by model is wrong once #1198 ships. That includes #916's smoke bench, #1138's Phase 0, and #944's baseline. It repeats #916 phase-0 confound 3 ("resolved-model ground truth was not captured").
Fix candidates (not prescribed)
- Pick the key with the most
outputTokens, or the highestcostUSD. - Prefer the key that matches the requested alias or role (
requestedModel/ the phase policy), and fall back to the one above. - Whichever you choose, it must not select an advisor model.
modelUsagecarries the advisor as its own key: a one-shotclaude -pprobe with an advisor configured returnedclaude-opus-5-5andclaude-fable-5-1as separate keys, and the advisor's input was entirely uncached. See feat(run): optional per-phase advisor model — measure first, then a retry rung between effort and model escalation #1138.
Acceptance criteria
- AC-1:
resolvedModelis the phase's main model whenmodelUsagelists a low-cost helper model first. Evidence:npx vitest run src/lib/workflow/phase-executor.test.tswith a fixture whose first key isclaude-haiku-4-5-20251001at ~$0 and whose second isclaude-sonnet-5with the real usage - AC-2:
resolvedModelnever selects an advisor-model key when the main model's usage is also present. Evidence:npx vitest run src/lib/workflow/phase-executor.test.tswith a fixture carryingclaude-opus-5-5(main) andclaude-fable-5-1(advisor, larger uncached input) - AC-3: The run log's per-phase
modeland the metrics' top-levelmodelfollow the corrected value. Evidence:npx vitest run src/lib/workflow/run-orchestrator.test.ts - AC-4: The comment at
phase-executor.ts:1804-1806describes the new rule, not "first key is the primary model". Evidence:grep -n "First key is the primary" src/lib/workflow/phase-executor.tsreturns nothing
Non-goals
- Rewriting existing metrics records.
phaseUsagealready holds the truth for them, and a reader can recompute from it. - Changing
phaseUsagerows.
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
fix(#1227): prefer the cached main loop when no model hint; drop stal…
fix(#1227): resolvedModel picks the phase's main model, not the first…
admarble commentedon Sep 30, 2026
Fixed by #1229 (squash
1d682113).selectResolvedModelnarrows to keys that match the dispatched model, then to keys with cache reads, then picks the largest token volume. Records written before this fix still carry Haiku inresolvedModel; theirphaseUsagerows hold the correct per-model data.docs(#1227): changelog entry for the resolvedModel fix (release ride-…
docs(#1227): state the resolvedModel selection rule accurately