Repository navigation
docs(providers): a Gemini CLI tool-call block whose body is not JSON streams as text - #320
Conversation
…streams as text The gemini-cli streaming bullet of CLI_PROVIDERS.md and the JSDoc of GeminiCLIProvider.generateCompletionStream() said that with tools the reply streams without its tool-call blocks, which arrive as the final chunk's tool calls alone. That holds for the blocks the provider reads as tool calls. A block whose body is not JSON is no tool call to parseToolCallsFromText(), which skips it, and ToolCallMarkupFilter lets it through as text; both now say so.
…streams as text streamText() with tools on the Gemini CLI provider, over a stubbed CLI that writes a complete <tool_call> block whose body JSON.parse rejects, split across deltas between two pieces of prose. parseToolCallsFromText() reads no tool call in it, so the block must reach the consumer as one text part once its closing tag arrives, with no tool-call part.
Reviewer's GuideThis documentation-only behavior correction updates Gemini CLI streaming guidance and provider JSDoc to explain that only blocks successfully parsed as tool calls are removed from streamed text; blocks with non-JSON bodies pass through as text. A subprocess integration test verifies the behavior across split stream deltas without changing provider implementation code. Sequence diagram for Gemini CLI non-JSON tool-call block streamingsequenceDiagram
participant GeminiCLI
participant Bridge
participant GeminiCLIProvider
participant Consumer
GeminiCLI->>Bridge: stream-json message deltas
Bridge->>GeminiCLIProvider: streamText()
GeminiCLIProvider->>GeminiCLIProvider: ToolCallMarkupFilter.push()
Note over GeminiCLIProvider: Complete block body is not valid JSON
GeminiCLIProvider->>Consumer: text part containing the complete block
GeminiCLIProvider->>Consumer: final chunk without a tool call
Sequence diagram for parsed Gemini CLI tool-call block streamingsequenceDiagram
participant GeminiCLI
participant GeminiCLIProvider
participant Consumer
GeminiCLI->>GeminiCLIProvider: streamText() deltas
GeminiCLIProvider->>GeminiCLIProvider: parseToolCallsFromText()
Note over GeminiCLIProvider: Block body parses as JSON
GeminiCLIProvider->>Consumer: prose text without tool-call block
GeminiCLIProvider->>Consumer: final chunk with tool call
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
PR Summary by QodoClarify Gemini CLI streaming of non-JSON tool-call blocks
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can commit Qodo's fix in one click with committable suggestions (GitHub & GitLab) |
## [0.13.59](v0.13.58...v0.13.59) (2026-10-12) ### fix * **images:** transferStyle sends the source and the style reference (#322) ([32761ce](32761ce)) ### docs * **providers:** a Gemini CLI tool-call block whose body is not JSON streams as text (#320) ([76c0fe7](76c0fe7)) * thirteenth round of audit follow-ups (diagram alt texts, the PII page, HITL gaps) (#319) ([01dfe54](01dfe54))
Summary
A correction to two statements #315 added. The
gemini-clistreaming bullet ofdocs/getting-started/CLI_PROVIDERS.mdand the JSDoc ofGeminiCLIProvider.generateCompletionStream()said that, with tools, the reply streams without its tool-call blocks, which arrive as the final chunk's tool calls alone. That holds for the blocks the provider reads as tool calls, and not for a block whose body is not JSON:parseToolCallsFromText()parses each block's body withJSON.parseand skips a block whose body does not parse (src/core/llm/providers/implementations/GeminiCLIProvider.tsL196-199 at 48d82bb), so such a block is no tool call in the final chunk.ToolCallMarkupFilter.push()lets a complete block through as text whenparseToolCallsFromText(block)reads no tool call in it (L303; the class's own JSDoc says so at L268).Both statements now name the blocks the provider reads as tool calls, and say that a block whose body is not JSON streams as text (5a49287). The filter's branch that lets such a block through had no test; 91ba36d adds one. No provider code changes.
Linked issues
Follows #315.
Type of change
How this was verified
CI only; nothing was run on a workstation.
src/core/llm/providers/__tests__/cli-providers-subprocess.test.ts, throughstreamText()with a tool on the realgemini-cliprovider and bridge, the CLI stubbed as in fix(providers): structured-output replies always reach stream consumers, and Gemini tool-call markup never streams as text #315: prose, a complete block whose body is{city: Paris}split across three deltas, prose. The block must be one text part, given once its closing tag arrives, with no tool-call part, andtextmust be the whole reply. It guards behavior fix(providers): structured-output replies always reach stream consumers, and Gemini tool-call markup never streams as text #315 shipped, so it passes on master as well.cli-providers-subprocess.test.ts62 tests, one more than master's 61).Migration notes
None.
Checklist
!before the colon for a change that breaks users (feat!:orfeat(api)!:).