Skip to content

fix(ai): patch Gemini tool thought signatures#448

Open
codedogQBY wants to merge 1 commit into
mainfrom
codex/fix-gemini-thought-signatures
Open

fix(ai): patch Gemini tool thought signatures#448
codedogQBY wants to merge 1 commit into
mainfrom
codex/fix-gemini-thought-signatures

Conversation

@codedogQBY

@codedogQBY codedogQBY commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Analysis

  • [Bug] Gemini Ai Error 总结当前章节 #225 reports Gemini 3 returning 400 Function call is missing a thought_signature after the reader AI calls getCurrentChapter.
  • Google documents that Gemini 3 function-calling turns must send a tool_calls[].extra_content.google.thought_signature value back on the first function call part in each step.
  • LangChain's OpenAI-compatible conversion reserializes parsed tool calls and can drop provider-specific extra_content, so the next Gemini/OpenAI-compatible request can fail before the tool result is processed.

Changes

  • Patch Gemini/OpenAI-compatible POST request bodies in the endpoint fetch wrapper before sending them.
  • Preserve existing Gemini thought signatures when present.
  • Add the documented skip_thought_signature_validator fallback to missing first function tool calls for Gemini 3 / Google-compatible requests.
  • Add focused tests for Gemini 3 custom endpoints, existing signatures, and non-Gemini requests.

Verification

  • pnpm --filter @readany/core test -- llm-provider
  • pnpm --filter @readany/core exec tsc --noEmit
  • pnpm exec biome check packages/core/src/ai/llm-provider.ts packages/core/src/ai/__tests__/llm-provider.test.ts (passes with existing DeepSeek override warnings in llm-provider.ts)
  • git diff --check

Fixes #225

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.

[Bug] Gemini Ai Error 总结当前章节

1 participant