Skip to content

fix(providers): omit temperature for Claude Opus/Sonnet 4.6+#1180

Open
ojusave wants to merge 1 commit into
nextlevelbuilder:devfrom
ojusave:fix/anthropic-temperature-claude46
Open

fix(providers): omit temperature for Claude Opus/Sonnet 4.6+#1180
ojusave wants to merge 1 commit into
nextlevelbuilder:devfrom
ojusave:fix/anthropic-temperature-claude46

Conversation

@ojusave
Copy link
Copy Markdown

@ojusave ojusave commented May 30, 2026

Anthropic returns HTTP 400 when temperature is sent to claude-opus-4-6, claude-sonnet-4-6, and newer 4.x models. Agent summoning and chat both hardcode temperature; skip the field for affected model IDs.

Summary

Omit temperature from Anthropic Messages API request bodies when the model is Claude Opus/Sonnet 4.6 or newer. Summoning (temperature: 0.7 in summoner_regenerate.go) and chat paths both flow through buildRequestBody; filtering at the provider adapter fixes both without changing every call site.

Type

  • Feature
  • Bug fix
  • Hotfix (targeting main)
  • Refactor
  • Docs
  • CI/CD

Target Branch

dev

Checklist

  • go build ./... passes
  • go build -tags sqliteonly ./... passes (if Go changes)
  • go vet ./... passes
  • Tests pass: go test -race ./...
  • Web UI builds: cd ui/web && pnpm build (if UI changes) — N/A, no UI changes
  • No hardcoded secrets or credentials
  • SQL queries use parameterized $1, $2 (no string concat) — N/A, no SQL changes
  • New user-facing strings added to all 3 locales (en/vi/zh) — N/A, no new strings
  • Migration version bumped in internal/upgrade/version.go (if new migration) — N/A, no migration

Test Plan

  • Added TestAnthropicAdapterToRequest_SkipsTemperatureForClaude46: asserts temperature is omitted for claude-opus-4-6, claude-sonnet-4-6, and claude-opus-4-7-*, and still sent for claude-sonnet-4-5-20250929.
  • Ran go build ./..., go build -tags sqliteonly ./..., go vet ./..., and go test -race ./... locally; all pass.
  • Manual repro (pre-fix): agent summoning with claude-opus-4-6 returned Anthropic 400 (temperature is deprecated for this model). Post-fix: request omits temperature and summoning succeeds.

Anthropic returns HTTP 400 when temperature is sent to claude-opus-4-6,
claude-sonnet-4-6, and newer 4.x models. Agent summoning and chat both
hardcode temperature; skip the field for affected model IDs.
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