Skip to content

feat: add support for Gemini extra_content in tool calls#745

Open
ivanmestre wants to merge 1 commit intoopenai-php:mainfrom
ivanmestre:fix-missing-thought-signature-tools-gemini
Open

feat: add support for Gemini extra_content in tool calls#745
ivanmestre wants to merge 1 commit intoopenai-php:mainfrom
ivanmestre:fix-missing-thought-signature-tools-gemini

Conversation

@ivanmestre
Copy link
Contributor

What:

  • Bug Fix
  • New Feature

Description:

This PR adds support for the extra_content payload returned by Gemini API tool calls, which includes provider-specific data like thought_signature.

Changes Introduced:

  • Added new DTOs: Created CreateResponseToolCallExtraContent and CreateResponseToolCallExtraContentGoogle to capture the Gemini payloads.
  • Updated existing DTO: Added ?CreateResponseToolCallExtraContent $extra_content to CreateResponseToolCall.
  • Cross-Provider Compatibility: Modified toArray() methods across these DTOs to strip the extra_content and google keys when they are null or empty.

Why filter null values?

APIs with strict schema validation (like Mistral) throw "Extra inputs are not permitted" errors if they receive "extra_content": null in the message history. Conditionally stripping these keys ensures developers can seamlessly reuse these response objects across different API providers without writing custom payload-stripping logic.

- Created `CreateResponseToolCallExtraContent` and `CreateResponseToolCallExtraContentGoogle` DTOs to handle Gemini's specific tool call payloads (e.g., thought signatures).
- Added `?CreateResponseToolCallExtraContent $extra_content` to `CreateResponseToolCall`.
- Updated `toArray()` methods across these DTOs to dynamically strip `extra_content` when null or empty, preventing strict schema validation errors in other providers like Mistral.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant