🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

fix: stop sending adaptive thinking to pre-4.6 Anthropic models - #27314

Merged
ibetitsmike merged 3 commits into
mainfrom
mike/chatd-anthropic-legacy-effort
Jul 18, 2026
Merged

fix: stop sending adaptive thinking to pre-4.6 Anthropic models#27314
ibetitsmike merged 3 commits into
mainfrom
mike/chatd-anthropic-legacy-effort

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Problem

A chat model config with reasoning_effort set on a pre-4.6 Anthropic model (for example claude-haiku-4-5) fails every generation with HTTP 400 adaptive thinking is not supported on this model, surfaced in chat as "Anthropic returned an unexpected error." The fantasy Anthropic provider always serialized effort as thinking: {type: "adaptive"} plus output_config.effort, a shape only Claude 4.6+ accepts.

Changes

  • Bump the coder/fantasy pin to include fix(providers/anthropic): convert reasoning effort to budget thinking on pre-4.6 models fantasy#47: the provider now converts effort into {type: "enabled", budget_tokens} on models older than Claude 4.6, with the budget derived from the call's max_tokens (aibridge-mirroring ratios, 1024-token API floor; below the floor thinking is omitted, which keeps small-budget calls like title generation working). Adaptive-capable models keep the current shape, and Opus 4.5 keeps output_config.effort alongside the derived budget since it supports effort without adaptive thinking. Models older than Claude 3.7 predate extended thinking, so effort sends no thinking at all there. minimal is normalized to low, xhigh falls back to max on adaptive models that predate the xhigh tier (Claude 4.7+); effort none disables thinking, including an explicit thinking: {type: "disabled"} on Claude 5+ models that otherwise run adaptive thinking by default. The Bedrock provider wraps the Anthropic one, so both are covered, and Vertex-style @date model IDs parse correctly.
  • TestActiveServer_CompactionModelOverride previously codified the buggy shape (asserting output_config.effort sent to claude-3-5-haiku-latest). The summary-routing subtest is now a three-case table: pre-thinking override models (Claude 3.5) expect no thinking, legacy budget-thinking ones (Haiku 4.5) expect enabled thinking with the derived budget, adaptive-capable ones still expect output_config.effort.
  • New regression test TestActiveServer_AnthropicModelReasoningEffort: a claude-haiku-4-5 config with reasoning_effort produces enabled thinking with the derived budget and no output_config on the wire, and a claude-sonnet-5 config with effort none sends an explicit thinking disable.
  • chattest.AnthropicRequest gains a Thinking field so tests can assert the thinking config.
  • One-sentence note in the chatd ARCHITECTURE reasoning-effort section.

No chatd production code changes: ApplyReasoningEffort keeps setting Effort, which is now valid for every Anthropic model.

Validation

  • go test ./coderd/x/chatd/... passes (19 packages).
  • Fork PR validated separately: full fantasy test suite plus new provider unit tests (version gating incl. Vertex/Bedrock IDs, budget derivation, floor behavior, normalization, effort none incl. Claude 5+ disable, Opus 4.5 effort preservation, sampling-param stripping), golangci-lint clean.

Closes CODAGT-812.

This PR was authored by Mux, an AI coding agent, acting on Mike's behalf.

@ibetitsmike ibetitsmike changed the title fix(coderd/x/chatd): stop sending adaptive thinking to pre-4.6 Anthropic models fix: stop sending adaptive thinking to pre-4.6 Anthropic models Jul 17, 2026
@ibetitsmike
ibetitsmike force-pushed the mike/chatd-anthropic-legacy-effort branch from 2cfe034 to 918973c Compare July 18, 2026 17:00
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 918973c06f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread go.mod Outdated
@ibetitsmike
ibetitsmike force-pushed the mike/chatd-anthropic-legacy-effort branch from 918973c to ce9feca Compare July 18, 2026 17:17
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: ce9feca8e4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike force-pushed the mike/chatd-anthropic-legacy-effort branch from ce9feca to 5d75eaa Compare July 18, 2026 17:29
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 5d75eaa081

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@ibetitsmike
ibetitsmike force-pushed the mike/chatd-anthropic-legacy-effort branch from 5d75eaa to 4d592f5 Compare July 18, 2026 17:39
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 4d592f54e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…pic models

A model config with reasoning_effort on a legacy Anthropic model such
as claude-haiku-4-5 failed every generation with HTTP 400 "adaptive
thinking is not supported on this model", because the fantasy
Anthropic provider always serialized effort as adaptive thinking plus
output_config.effort.

Bump the coder/fantasy pin to coder/fantasy#47, which converts effort
into enabled budget thinking (budget derived from max_tokens) on
models older than Claude 4.6 and keeps the adaptive shape for newer
ones. Effort values outside the API enum are normalized, and none now
disables thinking entirely.

Update the compaction override test to cover both the legacy and the
adaptive-capable request shapes, and add a regression test asserting
a claude-haiku-4-5 config with reasoning_effort produces enabled
thinking with the derived budget and no output_config.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@ibetitsmike
ibetitsmike force-pushed the mike/chatd-anthropic-legacy-effort branch from 4d592f5 to b321451 Compare July 18, 2026 17:47
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: b32145106f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…legacy-effort

# Conflicts:
#	coderd/x/chatd/chatd_test.go
coder/fantasy#47 merged; replace the PR-head pseudo-version with the
squash commit a63de4b40315 on coder_2_33 (identical tree).
@linear-code

linear-code Bot commented Jul 18, 2026

Copy link
Copy Markdown

CODAGT-812

@ibetitsmike
ibetitsmike merged commit 5f5efa4 into main Jul 18, 2026
32 of 33 checks passed
@ibetitsmike
ibetitsmike deleted the mike/chatd-anthropic-legacy-effort branch July 18, 2026 20:47
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants