-
Notifications
You must be signed in to change notification settings - Fork 6.6k
fix: preserve extra_content (thought_signature) for Gemini multi-turn #7586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… tool calls Gemini models include a thought_signature in extra_content of tool call responses that must be echoed back in subsequent requests. Without this, multi-turn conversations with tool calls fail with 400 Bad Request. Changes: - Add extra_content field to ResponseItem::FunctionCall in models.rs - Capture extra_content from SSE tool_calls delta in sse/chat.rs - Include extra_content in outgoing request JSON in requests/chat.rs The extra_content field uses #[serde(default)] for backward compatibility and skip_serializing_if for clean output with non-Gemini providers.
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Update all call sites that construct ResponseItem::FunctionCall to include the new extra_content field, restoring buildability.
|
@etraut-openai sir, can we go ahead with the review of this PR or is there any issue here? |
|
@gut-puncture, the team hasn't had time to review this PR yet. There are others ahead of it in the queue. |
Fix: Preserve
extra_contentfor Gemini Multi-Turn Tool CallsFixes #7519
Problem
When using Gemini 3 Pro via the OpenAI compatibility layer, multi-turn tool call conversations fail with:
Root Cause
Gemini models include a
thought_signaturewithinextra_content.google.thought_signaturein tool call responses. This signature must be echoed back in subsequent requests for the model to maintain context. The CLI was discarding this field.Solution
Added support for preserving and echoing
extra_contentin the Chat Completions API path:1.
protocol/src/models.rsAdded
extra_contentfield toResponseItem::FunctionCall:2.
codex-api/src/sse/chat.rsCapture
extra_contentfrom SSE tool call deltas:3.
codex-api/src/requests/chat.rsInclude
extra_contentin outgoing request JSON:Backward Compatibility
#[serde(default)]- Existing data withoutextra_contentdeserializes correctlyskip_serializing_if = "Option::is_none"- Output stays clean for non-Gemini providers..pattern matching - 20+ existing code paths automatically ignore the new fieldTesting
Related
provider_metadatacontainingthought_signature