Skip to content

fix: group parallel OpenAI tool results into one Gemini content - #153

Merged
lich0821 merged 1 commit into
lich0821:masterfrom
pcbeingused333:fix/openai-gemini-parallel-tool-results
Oct 27, 2026
Merged

lich0821 merged 1 commit into
lich0821:masterfrom
pcbeingused333:fix/openai-gemini-parallel-tool-results

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

When an assistant message makes parallel tool calls, OpenAI clients answer with one tool message per call. OpenAIReqToGemini turned each of them into its own user content holding one functionResponse. Gemini expects the responses to a parallel function call turn together in a single content, with as many functionResponse parts as there were functionCall parts, and rejects the request when they are split.

A tool message that directly follows another tool message now adds its functionResponse part to the previous content, in call order. A single tool result, and tool results of different turns (separated by other messages), still produce one content each.

Tests: openai_gemini_tool_results_test.go covers two parallel results in one content, and a single result plus a later user turn and second tool round staying apart; the first fails on master. go vet and go test ./internal/... pass. Not run against the live Gemini API.

This change was prepared with AI assistance (Claude Code).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@lich0821
lich0821 merged commit 18dc25c into lich0821:master Oct 27, 2026
7 checks passed
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.

2 participants