Skip to content

fix: send OpenAI developer and list-content system messages as Gemini systemInstruction - #152

Merged
lich0821 merged 1 commit into
lich0821:masterfrom
pcbeingused333:fix/openai-gemini-developer-role
Oct 27, 2026
Merged

lich0821 merged 1 commit into
lich0821:masterfrom
pcbeingused333:fix/openai-gemini-developer-role

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

OpenAIReqToGemini only treated a message with role: "system" and a plain string as a system instruction. Two inputs that OpenAI clients send went wrong:

  • A developer message (the role newer OpenAI clients use for instructions) was not recognised, so it was put in contents with role: "developer", which Gemini does not accept (only user and model).
  • A system message whose content is a list of text parts ([{"type": "text", "text": ...}]) was dropped silently, because only string content was read.

Both roles now go through extractSystemText (already used for Claude system prompts, it reads a string or a list of text parts) and are joined, in order, into systemInstruction. Requests with a plain system string produce the same output as before.

Tests: openai_gemini_system_test.go covers a developer string, a system list of parts, and a mix of both in order, and checks that contents only carries user and model; all three fail 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).

… systemInstruction

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@lich0821
lich0821 merged commit 7fd1225 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