Skip to content

fix(harness): clear error for unknown model id (dot-vs-dash guard) + M6 spec notes - #4

Merged
pdettori merged 1 commit into
mainfrom
fix/m6-model-guard
Jun 25, 2026
Merged

pdettori merged 1 commit into
mainfrom
fix/m6-model-guard

Conversation

@pdettori

Copy link
Copy Markdown
Member

Clear error for unknown model id (+ M6 spec notes)

Follow-up to the merged M6 PR #3. Surfaced while running the live E5 experiment through the litellm gateway.

Problem

getModel(provider, modelId) returns undefined for an id not in the pi-ai registry. A common trap: the dotted claude-sonnet-4.6 is a github-copilot key, while the anthropic id is the dash-form claude-sonnet-4-6. Left unguarded, run-turn then crashes cryptically on the gateway branch:

TypeError: Cannot read properties of undefined (reading 'headers')  (run-turn.ts)

Fix

requireModel(provider, modelId) wraps the lookup and throws a clear, actionable error:

  • known provider, unknown id → a dot/dash "Did you mean: claude-sonnet-4-6?" suggestion (normalizes ./-), or the known ids;
  • unknown provider → names the valid providers.

run-turn uses requireModel in place of the raw getModel call. Behavior is unchanged for valid ids; defaults still resolve to anthropic/claude-opus-4-8.

Tests

harness/test/run-turn-model.test.ts: +3 cases (known id resolves; dot-vs-dash trap throws naming the dash form; unknown provider throws naming valid providers). 7/7 green, no LLM key needed.

Docs

M6 spec updated: §4.2 documents the guard; §7 records the headless-lifecycle finding (session_start is not emitted in the headless runTurn path — the root cause of the budget-voter fix in PR #3) and flags the open question for M7: whether session_compact/turn_end likewise require bindExtensions (if so, the checkpoint marker is never written in production and openFromCheckpoint always falls back to full replay).

Assisted-By: Claude Code

getModel() returns undefined for an id not in the pi-ai registry (e.g. the
dotted claude-sonnet-4.6 is a github-copilot key; the anthropic id is the
dash-form claude-sonnet-4-6), which crashed cryptically on baseModel.headers.
Add requireModel(provider, modelId): throws a clear error with a dot/dash
'did you mean' suggestion (or known ids / known providers). Document the
guard and the headless-lifecycle finding (session_start not emitted; open
question on session_compact/turn_end) in the M6 spec.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
@pdettori
pdettori merged commit e684625 into main Jun 25, 2026
1 check passed
@pdettori
pdettori deleted the fix/m6-model-guard branch June 25, 2026 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant