fix(anthropic): stop sending temperature in non-thinking requests - #55
Open
Lucifus613 wants to merge 1 commit into
Open
Lucifus613 wants to merge 1 commit into
Lucifus613 wants to merge 1 commit into
Conversation
Anthropic Python SDK v1 removed temperature/top_p/top_k from messages.create (passing one raises TypeError), and Claude Opus 4.7+ rejects non-default sampling values with HTTP 400. The constructor, chat and stream keep accepting temperature for compatibility but no longer send it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This branch has not been deployed
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
AnthropicClient._build_kwargsstill sendstemperaturein non-thinking mode. Two problems follow:AsyncMessages.createno longer hastemperature,top_portop_kparameters, so passingtemperature=raisesTypeError. This was checked withinspect.signatureon anthropic 1.0.0 and 1.3.0.temperature,top_portop_kon Claude Opus 4.7 and later models returns a 400, and recommends omitting these parameters entirely. Sending them throughextra_bodygets the same 400.This PR stops writing
temperatureinto the request. The constructor,chatandstreamstill accept a temperature argument, so callers do not break. Thinking and effort handling are unchanged.Changes
agent_core/providers/anthropic.py: removed the non-thinkingtemperaturebranch and updated the comments to match.tests/test_provider_native_clients.py: three new tests.AsyncMessages.create.AsyncAnthropicclient over a mock transport has no sampling parameters in its body.tests/test_provider_protocol_reasoning.py: the old "keeps temperature when thinking is off" test now asserts that temperature is dropped.changes/a4-anthropic-omit-sampling.fix.md: changelog fragment.Test plan
Run on this branch, which is
mainplus this commit:python -m pytest tests -q: 1622 passed (anthropic 1.3.0, openai 3.7.0).ruff check agent_core tests: clean.maingive 6 failed and 91 passed; with this commit all pass.pyright agent_corereports 6 errors, all inagent_core/runtime/loop/agent_loop.py. Unmodifiedmainreports the same 6, and this PR does not touch that file.🤖 Generated with Claude Code