Skip to content

Default ChatOptions.Temperature to 0 so newer Claude models accept the request - #19

Merged
FMXExpress merged 1 commit into
mainfrom
claude/pr19-temperature-default
May 27, 2026
Merged

FMXExpress merged 1 commit into
mainfrom
claude/pr19-temperature-default

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Summary

Fixes the runtime error from pasclaw agent:

anthropic error 400: {"type":"error","error":{"type":"invalid_request_error",
"message":"`temperature` is deprecated for this model."}}

Anthropic deprecated the temperature field for newer Claude models — Opus 4.7 now returns 400 even with a perfectly valid value. The default of 0.7 in DefaultChatOptions meant the field was always emitted, even when no caller had explicitly picked a value.

Both the Anthropic and OpenAI request builders already gate the field on Options.Temperature > 0:

  • PasClaw.Providers.Anthropic.pas:108
  • PasClaw.Providers.OpenAI.pas:79

So changing the default to 0 ("not set") silently omits the field. Callers who want a specific temperature still set it via Options or config; otherwise providers fall back to their server-side default, which is what most users implicitly assumed they were getting from 0.7.

Test plan

  • pasclaw agent with Claude Opus 4.7 model: no more 400; reply streams normally
  • OpenAI provider still works (still gates on >0, no behavior change unless a caller relied on the implicit 0.7)
  • Explicit Options.Temperature := 0.7 before calling Chat() still sends the field

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon


Generated by Claude Code

…e request

Anthropic deprecated the temperature field for newer Claude models
(Opus 4.7 returns 400: \"\`temperature\` is deprecated for this model.\"
even with a perfectly valid value). The default of 0.7 in
DefaultChatOptions meant the field was always emitted, even when no
caller had explicitly picked a value.

Both the Anthropic and OpenAI request builders already gate the
field on Options.Temperature > 0, so changing the default to 0
('not set') silently omits the field. Callers who want a specific
temperature still set it via Options or config; providers fall back
to their server-side default otherwise, which is what most users
implicitly assumed they were getting.

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
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.

2 participants