Fix agent-host Claude sending reasoning effort to models that reject it#321698
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Claude Agent SDK sessions failing on models that reject reasoning effort (e.g. claude-haiku-4.5) by normalizing Claude model IDs to the SDK/CLI’s dashed format at all SDK seams and ensuring stale effort is explicitly cleared when switching to no-effort models.
Changes:
- Add
toSdkModelId()and use it when passing model IDs into the Claude Agent SDK (startup options, runtimesetModel, pipeline seeding), while preserving endpoint-format IDs elsewhere. - Explicitly clear runtime reasoning effort when switching to a model that resolves to
undefinedeffort viaapplyFlagSettings({ effortLevel: null }). - Add/extend unit tests covering model-id normalization and effort-clearing behavior.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/agentHost/test/node/claudeSdkPipeline.test.ts | Adds a recorder warm/query double and new setEffort tests to validate effort clearing/pushing behavior. |
| src/vs/platform/agentHost/test/node/claudeModelId.test.ts | Adds standalone unit coverage for toSdkModelId() normalization and passthrough behavior. |
| src/vs/platform/agentHost/node/claude/claudeSdkPipeline.ts | Updates setEffort to treat undefined as “clear” via effortLevel: null. |
| src/vs/platform/agentHost/node/claude/claudeSdkOptions.ts | Normalizes Options.model to SDK format at startup using toSdkModelId(). |
| src/vs/platform/agentHost/node/claude/claudeProxyService.ts | Documents and performs SDK→endpoint model-id rewrite for /v1/messages requests. |
| src/vs/platform/agentHost/node/claude/claudeModelId.ts | Introduces toSdkModelId() helper to normalize endpoint-format IDs to SDK format. |
| src/vs/platform/agentHost/node/claude/claudeAgentSession.ts | Normalizes model IDs for pipeline seeding/runtime setModel, and always calls setEffort (including undefined) to clear stale effort. |
| src/vs/platform/agentHost/node/claude/claudeAgent.ts | Documents that ModelSelection.id is canonicalized in endpoint (dotted) format and must be normalized at SDK seams. |
Copilot's findings
- Files reviewed: 8/8 changed files
- Comments generated: 1
7e14b0e to
a09d81c
Compare
Contributor
|
Base:
|
The agent host passed the CAPI/endpoint model id (dotted, e.g. `claude-haiku-4.5`) to the Claude SDK/CLI, which keys its model table by the SDK format (dashed, `claude-haiku-4-5`). Given an unrecognized id the CLI falls back to a generic request shape (adaptive thinking + reasoning effort `high`); CAPI then 400s for models that don't support effort (`output_config.effort "high" ... does not support reasoning effort`). Normalize the id to SDK format via `toSdkModelId` at every SDK seam (startup options, runtime setModel, seed), and document the dotted/dashed boundary at the origin and the proxy round-trip. Also clear stale runtime effort when switching to a no-effort model. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
a09d81c to
6648b83
Compare
DonJayamanne
approved these changes
Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes https://github.com/microsoft/vscode-internalbacklog/issues/8031
Fresh agent-host Claude sessions on
claude-haiku-4.5failed with:Root cause: the agent host passed the CAPI/endpoint model id (dotted,
claude-haiku-4.5) straight to the Claude SDK/CLI, but the CLI keys its internal model table by the SDK format (dashed,claude-haiku-4-5). Given an id it doesn't recognize, the CLI falls back to a generic full-feature request —thinking: { type: "adaptive" }+output_config: { effort: "high" }— which CAPI rejects for models that don't support reasoning effort. Our ownOptions.effortwas alreadyundefined; the effort came entirely from the CLI's unknown-model fallback.Fix
toSdkModelId()and normalize the model id to SDK format at every SDK seam (buildOptionsstartup, runtimesetModel, pipeline seed). Codename / non-Claude ids pass through unchanged.claudeAgent.toAgentModelInfo) and the proxy round-trip (/v1/messagesrewrite).setEffort(undefined)→applyFlagSettings({ effortLevel: null })).Validation
/v1/messagescapture endpoint, no CAPI): dotted id →output_config.effort: "high"; dashed id → nooutput_config, correctthinking: { type: "enabled" }.toSdkModelIdnormalization +ClaudeSdkPipelineeffort suite); cleantsgotype-check.Test plan
chat.agents.claude.preferAgentHost: true, start a Claude session on Haiku 4.5 and send a message → no 400, model responds.🤖 Generated with Claude Code