Skip to content

bug(metrics): resolvedModel records the Haiku helper, not the phase's model, since 2026-09-20 — first modelUsage key is no longer the main model #1227

Closed

Description

@admarble

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>.resolvedModel recorded from 2026-09-20 onward is claude-haiku-4-5-20251001, across runs whose policy was sonnet or opus. Every run through 2026-09-19 records the real model. The change happened between 2026-09-19T07:23Z and 2026-09-20T13:10Z.
  • The phaseUsage rows 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

  1. 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.
  2. 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 three model: …resolvedModel sites).
  3. 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 read opus. 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)

Acceptance criteria

  • AC-1: resolvedModel is the phase's main model when modelUsage lists a low-cost helper model first. Evidence: npx vitest run src/lib/workflow/phase-executor.test.ts with a fixture whose first key is claude-haiku-4-5-20251001 at ~$0 and whose second is claude-sonnet-5 with the real usage
  • AC-2: resolvedModel never selects an advisor-model key when the main model's usage is also present. Evidence: npx vitest run src/lib/workflow/phase-executor.test.ts with a fixture carrying claude-opus-5-5 (main) and claude-fable-5-1 (advisor, larger uncached input)
  • AC-3: The run log's per-phase model and the metrics' top-level model follow the corrected value. Evidence: npx vitest run src/lib/workflow/run-orchestrator.test.ts
  • AC-4: The comment at phase-executor.ts:1804-1806 describes the new rule, not "first key is the primary model". Evidence: grep -n "First key is the primary" src/lib/workflow/phase-executor.ts returns nothing

Non-goals

  • Rewriting existing metrics records. phaseUsage already holds the truth for them, and a reader can recompute from it.
  • Changing phaseUsage rows.

Relates to #975, #1198, #986, #916, #1138.

Activity

  1. added
    bug
    on Sep 30, 2026
  2. added 2 commits that reference this issue on Sep 30, 2026
  3. admarble commented on Sep 30, 2026

    @admarble
    ContributorAuthor

    Fixed by #1229 (squash 1d682113). selectResolvedModel narrows 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 in resolvedModel; their phaseUsage rows hold the correct per-model data.

  4. added 2 commits that reference this issue on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions