Skip to content

Fix Claude Code smart routing: opus-4-8 pin, model name mapping, subagent prompt - #284

Open
masonc08 wants to merge 5 commits into
mainfrom
claude-smart-routing-fixes
Open

Fix Claude Code smart routing: opus-4-8 pin, model name mapping, subagent prompt#284
masonc08 wants to merge 5 commits into
mainfrom
claude-smart-routing-fixes

Conversation

@masonc08

@masonc08 masonc08 commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Four fixes for Claude Code smart routing, all tested end-to-end against a live workspace.

1. Pin opus-4-8 in discovery (databricks.py)

Discovery's newest-wins family bucketing picks claude-opus-5 over claude-opus-4-8, but the deployed task_v1 router's cc scenario requires claude-opus-4-8 as a route arm. Pin opus-4-8 when both exist so the routing availability check passes. Revert once the router accepts opus-5 (databricks-eng/universe#2365446).

2. Map subagent model to short family name (claude_routing.py)

Claude Code's Agent tool model field only accepts short family names (sonnet, opus, haiku, fable), not full workspace ids. The PreToolUse hook was injecting the full id (e.g. system.ai.claude-sonnet-5), which Claude Code rejected with a schema validation error. Map the router's pick back to its family name before injecting.

3. Don't report mismatch when harness omits subagent model (routing.py, cli.py)

Claude Code's SubagentStart event does not include the subagent's model field, so the reconciliation audit recorded model: null and reported a false mismatch ("router requested sonnet, but Claude Code started None"). When the actual model is unknown, record matches_router_decision: None (unknown) rather than False (mismatch), and emit no SubagentStart message — the PreToolUse hook already injected the routed model.

4. Send Claude subagent prompt to router (routing.py)

route_spawn_tool looked for message/task_name/agent_name to derive the routing task, but Claude Code's Agent tool puts the subagent task in prompt/description. So Claude always fell through to the generic "Claude Code subagent task" label, and the router made decisions on a constant string. Add prompt and description to the front of the field fallback chain. Safe for Codex: its spawn_agent tool uses message, which is absent from Claude payloads, and vice versa.

This pull request and its description were written by Isaac.

Discovery's newest-wins family bucketing picks claude-opus-5 over
claude-opus-4-8, but CLAUDE_ROUTE_ARMS hardcodes claude-opus-4-8 — so
the routing availability check fails with 'required Claude routing
models are unavailable: claude-opus-4-8' on workspaces that have both.

Pin the opus slot to 4-8 when both exist so routing works with the
currently-deployed task_v1 router. Revert once the router accepts
opus-5 (PR databricks-eng/universe#2365446).
Claude Code's Agent tool model field only accepts short family names
(sonnet, opus, haiku, fable), not full workspace ids. The PreToolUse hook
was injecting the full id (e.g. system.ai.claude-sonnet-5) into
updatedInput.model, which Claude Code rejected with a schema validation
error. Map the router's pick back to its family name before injecting.
Claude Code's SubagentStart event does not include the subagent's model
field, so the reconciliation audit recorded model=null and reported a
false mismatch. When the actual model is unknown, record
matches_router_decision as None (unknown) rather than False (mismatch),
and emit no SubagentStart message to the user — the PreToolUse hook
already injected the routed model.
route_spawn_tool looked for message/task_name/agent_name to derive the
routing task, but Claude Code's Agent tool puts the subagent task in
prompt/description — so Claude always fell through to the generic
"Claude Code subagent task" label, and the router made decisions on a
constant string. Add prompt and description to the front of the field
fallback chain. Safe for Codex: its spawn_agent tool uses message, which
is absent from Claude payloads, and vice versa.
@masonc08
masonc08 marked this pull request as ready for review August 6, 2026 23:49
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