Skip to content

fix(anthropic): guard thinking kwargs for older SDKs#5782

Open
bg-l2norm wants to merge 1 commit into
NousResearch:mainfrom
bg-l2norm:fix/issue-5777-anthropic-thinking-compat
Open

fix(anthropic): guard thinking kwargs for older SDKs#5782
bg-l2norm wants to merge 1 commit into
NousResearch:mainfrom
bg-l2norm:fix/issue-5777-anthropic-thinking-compat

Conversation

@bg-l2norm

Copy link
Copy Markdown
Contributor

Fixes #5777.

Root cause

  • Hermes now adds Anthropic thinking / output_config kwargs when reasoning is enabled.
  • Older anthropic SDKs do not accept those kwargs.
  • hermes update can update the repo without reinstalling Python deps, so an older SDK can still be in the existing env.
  • That turns into Messages.create() got an unexpected keyword argument 'thinking' before the request even reaches MiniMax.

What changed

  • Added a small SDK compatibility check against anthropic.resources.messages.Messages.create.
  • If the installed SDK does not support thinking, Hermes now skips reasoning kwargs instead of crashing.
  • If thinking is supported but output_config is not, Hermes sends adaptive thinking without output_config.
  • Added regression tests for both cases.

Repro / verification

  • Reproduced locally with a project-local .venv311 using anthropic==0.39.0.
  • Before fix: kwargs included thinking, and a Messages.create(...)-style call raised the same TypeError.
  • After fix: kwargs omit thinking/output_config, and the same call shape succeeds.

Checks

  • python -m pytest -o addopts='' tests/test_anthropic_adapter.py -q -k 'reasoning_config or reasoning_disabled or sdk_lacks_thinking or adaptive_thinking_omits_output_config'
  • python -m py_compile agent/anthropic_adapter.py tests/test_anthropic_adapter.py

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder provider/anthropic Anthropic native Messages API labels Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists provider/anthropic Anthropic native Messages API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Error: Messages.create() got an unexpected keyword argument 'thinking'

2 participants