Repository navigation
Description
Bug Description
When using Cerebras as a custom provider, multi-turn agent sessions with tool calling fail with HTTP 400 after the first retry:
messages.2.assistant.reasoning_content: property 'reasoning_content' is unsupported
Root Cause
In agent/agent_runtime_helpers.py → copy_reasoning_content_for_api() (line ~2093):
existing = source_msg.get("reasoning_content")
if isinstance(existing, str):
if existing == "" and agent._needs_thinking_reasoning_pad():
api_msg["reasoning_content"] = " "
else:
api_msg["reasoning_content"] = existing # ← Always copies!
returnWhen reasoning_content is a non-empty string, it's always copied to the API message, regardless of whether the current provider supports it. The _needs_thinking_reasoning_pad() check only applies to the empty-string upgrade case.
Cerebras returns reasoning_tokens in responses (via the OpenAI-compatible API), which Hermes stores as reasoning_content. On replay (e.g., after a 429 rate-limit retry), this reasoning_content is included in the messages array, and Cerebras rejects it because their API doesn't accept that field in input messages.
To Reproduce
-
Configure Cerebras as a custom provider:
providers: custom:cerebras: base_url: https://api.cerebras.ai/v1 api_key: csk-... models: ["gpt-oss-120b", "zai-glm-4.7"]
-
Run an agent task with tool calling:
hermes chat -q "Create a file /tmp/test.txt and read it back" --provider custom:cerebras --model gpt-oss-120b -
Observe:
- First tool call succeeds (write_file)
- Second call hits rate limit (429)
- Retry sends
reasoning_contentin messages → Cerebras returns 400
Expected Behavior
reasoning_content should be stripped from API messages when the provider doesn't support it. Only providers that explicitly require it (DeepSeek, Kimi, MiMo — per _needs_thinking_reasoning_pad()) should receive it.
Proposed Fix
In copy_reasoning_content_for_api(), add a provider check before copying non-empty reasoning_content:
existing = source_msg.get("reasoning_content")
if isinstance(existing, str):
if existing == "" and agent._needs_thinking_reasoning_pad():
api_msg["reasoning_content"] = " "
elif agent._needs_thinking_reasoning_pad():
api_msg["reasoning_content"] = existing
# else: strip reasoning_content for providers that don't support it
returnOr alternatively, add a _strips_reasoning_content() method for providers like Cerebras that reject the field.
Environment
- Hermes version: 0.16.0
- Provider: custom:cerebras (https://api.cerebras.ai/v1)
- Models: gpt-oss-120b, zai-glm-4.7
- Cerebras API returns reasoning_tokens but rejects reasoning_content in input messages
Workaround
None available via config — this requires a code fix.
Activity
fix(agent): strip stale reasoning_content when falling back to a stri…
fix(agent): strip stale reasoning_content when falling back to a stri…
fix(agent): strip stale reasoning_content when falling back to a stri…
fix(agent): strip stale reasoning_content when falling back to a stri…
chore(upstream): sync fork to NousResearch tip (89540d5, +2140) (#15)
fix(agent): strip stale reasoning_content when falling back to a stri…
fix(agent): strip stale reasoning_content when falling back to a stri…
fix(agent): strip stale reasoning_content when falling back to a stri…
fix(agent): strip stale reasoning_content when falling back to a stri…
teknium1 commentedon Jul 14, 2026
Implemented on current
main— automated hermes-sweeper review.fix(agent): strip stale reasoning_content when falling back to a strict provider (#50480)) explicitly covers Cerebras API rejects reasoning_content on multi-turn replay (HTTP 400) #45655 and Cerebras.agent/agent_runtime_helpers.py:2821-2838now removesreasoning_contentfor providers that do not require echo-back, including non-empty values.agent/agent_runtime_helpers.py:2920-2938also strips stale fields from already-built retry/fallback API messages.tests/run_agent/test_run_agent.py:7300-7337verifies replayed strict-provider requests omit the field.The fix is contained in release tag
v2026.7.1.fix(agent): strip stale reasoning_content when falling back to a stri…
fix(agent): strip stale reasoning_content when falling back to a stri…
fix(agent): strip stale reasoning_content when falling back to a stri…
fix(agent): strip stale reasoning_content when falling back to a stri…