Skip to content

fix(gemini): fix tool calling and thought-signature round-trip - #1389

Merged
sailist merged 1 commit into
MoonshotAI:mainfrom
sailist:fix/gemini-tool-calling
Jul 5, 2026
Merged

fix(gemini): fix tool calling and thought-signature round-trip#1389
sailist merged 1 commit into
MoonshotAI:mainfrom
sailist:fix/gemini-tool-calling

Conversation

@sailist

@sailist sailist commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue. The problem is described below.

Problem

Tool calling was broken for the Google Gemini provider: tool definitions, system prompts, and most sampling/thinking settings were silently dropped before reaching the model, so Gemini models never issued tool calls. Separately, on Gemini 3 thinking models the thought signature returned with a function call was not echoed back, so the turn after a tool call was rejected.

What changed

  • Send tool declarations, function calls/responses, system instructions, and sampling/thinking settings in the field shape the Google SDK forwards, so they reach the model.
  • Carry tool-call extras (the Gemini 3 thought signature) through the loop tool-call event into the conversation context so it is echoed on the next turn.
  • Update and add tests for the corrected request shape and the signature round-trip, plus a changeset.

Verified end-to-end against a live Gemini model: a forced shell tool call executed and the model returned its final answer (exit 0).

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

- send tool declarations, system prompt, and sampling/thinking settings in the camelCase shape the Google SDK forwards so tool calls reach the model
- thread tool-call extras (thought signatures) through the loop tool-call event into context so Gemini 3 can resume a tool turn
- update and add tests for the corrected request shape and signature round-trip
@changeset-bot

changeset-bot Bot commented Jul 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1d90bac

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 5, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@1d90bac
npx https://pkg.pr.new/@moonshot-ai/kimi-code@1d90bac

commit: 1d90bac

@sailist
sailist merged commit ebdffc7 into MoonshotAI:main Jul 5, 2026
16 of 17 checks passed
This was referenced Jul 5, 2026
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.

1 participant