Skip to content

fix: enable gemini multi-turn tool calling via bidiAppend session resume#12

Open
FL-Penly wants to merge 1 commit intoYukaii:mainfrom
FL-Penly:fix/gemini-multi-turn-tool-calling
Open

fix: enable gemini multi-turn tool calling via bidiAppend session resume#12
FL-Penly wants to merge 1 commit intoYukaii:mainfrom
FL-Penly:fix/gemini-multi-turn-tool-calling

Conversation

@FL-Penly
Copy link
Copy Markdown

@FL-Penly FL-Penly commented Feb 23, 2026

Fixes #7

Gemini models fail at multi-turn tool calling because when tool results arrive, the handler unconditionally destroys the session and starts a fresh stream. Gemini then re-requests the same tool instead of continuing.

session-reuse.ts already had sendToolResultsToCursor() implemented but never wired up. This PR uses it to send tool results back via bidiAppend + sendResumeAction on the existing session, falling back to fresh-start if the session is gone or resume fails.

Previously, when tool results arrived in a new request, the handler
unconditionally destroyed the existing session and started a fresh
Cursor stream. This caused gemini models to fail at multi-turn tool
calling - they would loop or error after the first tool result.

The fix uses the already-implemented sendToolResultsToCursor() from
session-reuse.ts to send tool results back via bidiAppend on the
existing session, then calls sendResumeAction() to trigger server
continuation. Falls back to the original fresh-start behavior if the
session is gone or resume fails.

Tested with cursor/gemini-3-flash and cursor/gemini-3.1-pro, both
now correctly complete multi-turn tool call sequences.

Fixes Yukaii#7
@FL-Penly FL-Penly marked this pull request as draft February 23, 2026 12:39
@FL-Penly FL-Penly marked this pull request as ready for review February 23, 2026 12:40
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.

Received only "Error" for gemini series model

1 participant