fix: strip call_id and response_item_id from tool_calls for Mistral compatibility#864
Open
unmodeled-tyler wants to merge 2 commits intoNousResearch:mainfrom
Open
Conversation
…ompatibility Mistral's API strictly validates the Chat Completions schema and rejects unknown fields with 422 "Extra inputs are not permitted". The call_id and response_item_id fields were added for Codex Responses API support (ce175d7) but are not part of the Chat Completions spec. This extends the fix from PR NousResearch#253 (which stripped finish_reason) to also strip these internal fields before sending to strict APIs like Mistral. Changes: - Strip call_id and response_item_id from tool_calls in 3 locations: - Main conversation loop - _handle_max_iterations() - flush_memories() - Fix 429 rate limit handling (was incorrectly treated as non-retryable) - Update .gitignore with common patterns The Codex Responses API code path has built-in fallback logic that uses the 'id' field when call_id is not present, so this change is safe for both API modes.
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
call_idandresponse_item_idfrom tool_calls before sending to strict APIs like Mistral.gitignorewith common patternsProblem
Mistral's API strictly validates the Chat Completions schema and rejects unknown fields with
422 - Extra inputs are not permitted. Thecall_idandresponse_item_idfields were added for Codex Responses API support (ce175d7) but are not part of the Chat Completions spec.This extends the fix from PR #253 (which stripped
finish_reason) to also strip these internal fields.Changes
Strip
call_idandresponse_item_idfrom tool_calls in 3 locations:_handle_max_iterations()flush_memories()Fix 429 rate limit handling - Changed from non-retryable to retryable with exponential backoff
Update
.gitignore- Addedconfig.yaml,sessions/,*.log,.DS_Store,Thumbs.dbSafety
The Codex Responses API code path has built-in fallback logic that uses the
idfield whencall_idis not present, so this change is safe for both API modes:idfieldRelated
finish_reasonfor Mistralcall_id/response_item_idfor Codex ResponsesTesting
Tested with Mistral API via Telegram gateway - tool calls now work correctly without 422 errors.