Skip to content

feat: enhance OpenAI message conversion for Gemini compatibility#489

Draft
LeeroyDing wants to merge 2 commits intospacedriveapp:mainfrom
LeeroyDing:main
Draft

feat: enhance OpenAI message conversion for Gemini compatibility#489
LeeroyDing wants to merge 2 commits intospacedriveapp:mainfrom
LeeroyDing:main

Conversation

@LeeroyDing
Copy link

@LeeroyDing LeeroyDing commented Mar 25, 2026

Gemini API is... weird, to say the least. Should fix #461

Note

This PR enhances OpenAI message conversion to handle Gemini API's strict compatibility requirements. The Gemini API uses an OpenAI-compatible shim but has several quirks that differ from standard OpenAI:

Key changes:

  1. Added is_gemini parameter to convert_messages_to_openai() to conditionally handle Gemini-specific formatting
  2. Assistant message content is now an empty string "" instead of null when tool calls are present (required by Gemini)
  3. Tool calls now include an index field (0-based) in Gemini mode
  4. Tool result messages now include the function name field for Gemini (in addition to tool_call_id)
  5. Updated three call sites in SpacebotModel to pass the is_gemini flag based on ApiType
  6. Added comprehensive tests for both Gemini-specific and standard OpenAI behavior

Written by Tembo for commit 01a4f9f. This will update automatically on new commits.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 25, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 46e47ac1-38df-4fe7-80db-e3d2f12f8961

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Gemini using tools

1 participant