Repository navigation
fix(gemini): separate same-name parallel tool calls in streams - #8828
Conversation
|
The revised snapshot handling still splits one call when the first string-valued argument chunk is already complete JSON ( For example, feed these three events, followed by the normal STOP/usage event, to either streaming bridge:
The first argument string makes I reproduced this through
All eight snapshot checks pass on main and fail here. All four control scenarios pass here: stable IDs on every string, initially incomplete fragments plus final object, distinct explicit IDs, and independent anonymous native objects. The first two controls also pass on main; the latter two confirm the intended parallel-call improvement. The PR's existing 36 protocol checks and Could the state distinguish the string-argument stream mode even when its initial chunk is already valid, while preserving the new boundary for independent native object calls and changed explicit IDs? AI-only local investigation on macOS/Go 1.27.4. Inputs are synthetic compatibility-stream fixtures; no live Gemini request, tool execution, database, or deployment was tested. |
|
Retested at The PR’s current 52 protocol checks and go test -tags=unit ./internal/service -run '^(TestReview8828CompleteStringSnapshots|TestGeminiParallelToolStreams|TestGeminiTextDeltaMatchesLegacy)$' -count=1 -vThis resolves the specific duplicate-call regression I reported. AI-only local verification on macOS/Go 1.27.4 using synthetic upstream SSE; no live Gemini request or tool execution was tested. |
Problem
The Gemini Chat Completions and Messages streaming bridges identify an open tool call by function name. Two independent calls to the same function therefore share one downstream block: different argument objects concatenate into invalid JSON, while identical arguments can be discarded. Non-streaming conversion correctly preserves both calls.
Based on upstream main 530c5e3.
Resulting behavior
Non-streaming conversion, native Gemini passthrough, routing, retry and billing behavior are unchanged. Arbitrarily interleaved unfinished calls are outside this change. Without IDs, an identical object immediately following string args cannot be distinguished from a terminal snapshot; it is treated as the snapshot. A following native object is a new call. This assumption is documented and covered by tests.
Before / after
For two same-name native calls with IDs a and b and arguments {"path":"a"} and {"path":"b"}:
The complete-string regression identified during review is also covered: args string with ID a, matching ID-less args string, then matching args object with ID a now produce one call, preserving main's behavior. The preceding ddb7eac revision incorrectly produced three.
Regression evidence
All fixtures are synthetic native SSE and invoke the actual streaming bridges. Tests aggregate public Chat deltas by index and Messages events by block lifecycle, checking first-delta metadata, distinct call IDs, valid argument JSON, tool finish reasons and cached token usage.
The expanded suite retains all prior 36 checks and adds complete-string snapshots plus stable-ID, changed-ID, native-call-after-snapshot and late-ID-transition coverage. Main's converters were tested with the same fixtures under Go 1.27.4. The two additional transition scenarios account for four failures beyond the eight reported snapshot regressions.
Validation
For ce026a2 on Go 1.27.4, Linux amd64:
No live model request, external tool execution, production database access or deployment was used for this correction.
Toolchain security prerequisite
The repository's pinned Go 1.27.3 caused backend-security to fail on the existing net/http vulnerability GO-2026-6859. A separate commit upgrades Go to 1.27.4 and synchronizes backend/go.mod, all four workflow version assertions, all three Docker build images, and DEV_GUIDE.md. The original security gate is preserved; no exclusions are added. The current backend-security run reports no affected vulnerabilities.