feat(gemini): Phase 4 — SSE streaming tool use (functionCall chunks)#1767
Merged
feat(gemini): Phase 4 — SSE streaming tool use (functionCall chunks)#1767
Conversation
) Extend the Gemini SSE parser to handle `functionCall` parts streamed by the Gemini API, resolving the TODO added in #1639. - Add `GeminiStreamFunctionCall { name, args }` struct to `sse.rs` - Add `function_call: Option<GeminiStreamFunctionCall>` to `GeminiStreamPart` - Update `parse_gemini_sse_event()` to collect functionCall parts and emit `StreamChunk::ToolUse(Vec<ToolUseRequest>)` — single-pass, no accumulator needed (Gemini delivers each functionCall as a complete atomic object) - Add `StreamChunk::ToolUse(Vec<ToolUseRequest>)` variant to `provider.rs` - Handle new variant in `router/mod.rs` (ignore in cascade stream) and `legacy.rs` (warn-log with tool names, not handled in streaming path) - Add 8 unit tests covering single/multiple/no-args/null-args/mixed/ thinking/empty-name/text-regression cases - Remove TODO comment from #1639 Resolves #1659. Part of epic #1592.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the Gemini SSE parser to handle
functionCallparts streamed by the Gemini API, resolving the TODO added in #1639.GeminiStreamFunctionCall { name, args }struct insse.rswith cross-reference toGeminiFunctionCallingemini.rsfunction_call: Option<GeminiStreamFunctionCall>toGeminiStreamPartwith#[serde(rename = "functionCall")]parse_gemini_sse_event()to collectfunctionCallparts and emitStreamChunk::ToolUse(Vec<ToolUseRequest>)— single-pass, no accumulator needed (Gemini delivers eachfunctionCallas a complete atomic object per SSE event)StreamChunk::ToolUse(Vec<ToolUseRequest>)variant toprovider.rsrouter/mod.rs(ignored in cascade stream) andlegacy.rs(tracing::warn!with tool names — tool execution useschat_with_tools, not the streaming path)Resolves #1659. Part of epic #1592.
Test plan
cargo nextest run -p zeph-llm— 713/713 pass (8 new tests)cargo clippy --workspace --features full -- -D warnings— 0 warningscargo +nightly fmt --check— cleancargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins— 5516/5516 pass