fix: strip extra_content from tool_calls for strict APIs (Fireworks, Mistral)#18663
Closed
nateGeorge wants to merge 1 commit into
Closed
fix: strip extra_content from tool_calls for strict APIs (Fireworks, Mistral)#18663nateGeorge wants to merge 1 commit into
nateGeorge wants to merge 1 commit into
Conversation
…Mistral) Strict OpenAI-compatible providers like Fireworks reject tool_calls with extra_content fields with HTTP 400 'Extra inputs are not permitted'. This happens when Gemini 3 thinking models attach extra_content (thought_signature) to tool_calls, which gets replayed on subsequent API calls. - agent/transports/chat_completions.py: Strip extra_content from tool_calls in convert_messages() along with call_id/response_item_id - run_agent.py: Add extra_content to _sanitize_tool_calls_for_strict_api() _STRIP_KEYS set Fixes NousResearch#17986 (HTTP 400 on Fireworks custom endpoint — first turn only) Related: NousResearch#893, NousResearch#5183
Cyrene963
pushed a commit
to Cyrene963/hermes-agent
that referenced
this pull request
May 3, 2026
Community PRs applied: - NousResearch#18596: Enable secret redaction by default (SECURITY) - NousResearch#18650: Sanitize malformed tool messages + auto-recover on API 400 - NousResearch#18607: Emergency compression before max_iterations exhaustion - NousResearch#18603: Compression fallback to main model on 413 rate limit - NousResearch#18638: Pass threshold_percent on model switch - NousResearch#18663: Strip extra_content from tool_calls for strict APIs - NousResearch#18618: Forward explicit_api_key to OpenRouter - NousResearch#18632: Show cache tokens in /insights breakdown - NousResearch#18614: Add idempotency guard for patch duplicate loops - NousResearch#18600: Raise ValueError when HERMES_HOME unset in profile mode - NousResearch#18616: Allow ZWJ emoji in context files - NousResearch#18582: Reload .env on /restart - NousResearch#18547: Stabilize system prompt prefix for KV cache reuse - NousResearch#18692: Strip FTS5 operators from session search truncation terms Fix: Add order_by_last_active=True to list_sessions_rich call (pre-existing commit 142b4bf code sync)
This was referenced Jun 3, 2026
Contributor
|
Merged via PR #38543 (commit e8c3ac2) — your fix cherry-picked onto current main with your authorship preserved in git log. I extended the strip to be model-aware (keep extra_content for Gemini-family targets, which need the thought_signature replayed; strip it for strict providers like Fireworks/Mistral) so it doesn't regress Gemini-on-aggregator. Thanks for the fix and the clear root-cause writeup. Closes #17986. |
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
Fixes HTTP 400 errors on strict OpenAI-compatible providers (Fireworks, Mistral) when tool_calls contain
extra_contentfields.Problem
Gemini 3 thinking models attach
extra_content(thought_signature) to tool_calls for replay on subsequent API calls. When these messages are replayed to strict providers like Fireworks, they reject the request with:This causes the first message of every new session to fail on Fireworks, forcing fallback to other providers (issue #17986).
Changes
extra_contentfrom tool_calls inconvert_messages()alongside existingcall_id/response_item_idstrippingextra_contentto_sanitize_tool_calls_for_strict_api()_STRIP_KEYSsetTesting
tests/agent/transports/test_chat_completions.pytests/run_agent/test_provider_parity.pyRelated Issues