Gemini OpenAI-compatible endpoint: every tool call fails with 'tool_calls[0].index: expected number, received undefined' (thought_signature not round-tripped)
Author: automationmatnastik-starCreated Sep 16, 2026Updated Sep 16, 2026
Setting OPENAI_BASE_URL to Google's OpenAI-compatible endpoint (https://generativelanguage.googleapis.com/v1beta/openai) and routing the workbench agent driver to openai:gemini-3.8-flash (api: openai-completions) works for plain chat but every tool call fails:
Type validation failed … choices[0].delta.tool_calls[0].index: expected number, received undefinedMeasured chunk from Google (the first tool call of a course-building session, read …/stage-design/SKILL.md):
{"choices":[{"delta":{"role":"assistant","tool_calls":[{"extra_content":{"google":{"thought_signature":"…"}},"function":{"arguments":"{\"offset\":1,\"limit\":100,\"path\":\"/app/skills/agent-runtime/stage-design/SKILL.md\"}","name":"read"},"id":"call_297140","type":"function"}]},"index":0}],"model":"gemini-3.8-flash","object":"chat.completion.chunk"}Two gaps versus the OpenAI stream contract: no tool_calls[].index (required by @ai-sdk/openai's chunk schema), and extra_content.google.thought_signature, which Gemini 3 expects back on the assistant tool call in the next request. The existing compatibility fetch in lib/ai/providers.ts is the natural seam. PR follows.
Source: THU-MAIC/OpenMAIC