Skip to content

docs(providers): a Gemini CLI tool-call block whose body is not JSON streams as text - #320

Merged
jddunn merged 2 commits into
masterfrom
docs/gemini-cli-non-json-block
Oct 12, 2026
Merged

jddunn merged 2 commits into
masterfrom
docs/gemini-cli-non-json-block

Conversation

@jddunn

@jddunn jddunn commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Summary

A correction to two statements #315 added. The gemini-cli streaming bullet of docs/getting-started/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, and not for a block whose body is not JSON:

  • parseToolCallsFromText() parses each block's body with JSON.parse and skips a block whose body does not parse (src/core/llm/providers/implementations/GeminiCLIProvider.ts L196-199 at 48d82bb), so such a block is no tool call in the final chunk.
  • ToolCallMarkupFilter.push() lets a complete block through as text when parseToolCallsFromText(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

  • Bug fix
  • Feature
  • Performance
  • Documentation
  • Refactor
  • Tests
  • Build or CI

How this was verified

CI only; nothing was run on a workstation.

Migration notes

None.

Checklist

  • Tests cover the changed behavior.
  • Docs are updated.
  • The title follows Conventional Commits, with ! before the colon for a change that breaks users (feat!: or feat(api)!:).
  • No secrets or private data are included.
  • Every automated review thread is settled (how).
  • I have read this change and can explain every line.

…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.
@jddunn
jddunn requested a review from Victor-Evogor as a code owner October 12, 2026 02:35
@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This 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 streaming

sequenceDiagram
    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
Loading

Sequence diagram for parsed Gemini CLI tool-call block streaming

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Clarifies Gemini CLI streaming behavior for markup blocks that are not recognized as tool calls.
  • Updates provider documentation to distinguish parsed tool-call blocks from non-JSON blocks, which stream as text.
  • Aligns the provider method JSDoc with the actual JSON parsing and filtering behavior.
docs/getting-started/CLI_PROVIDERS.md
src/core/llm/providers/implementations/GeminiCLIProvider.ts
Adds regression coverage for non-JSON tool-call markup in streamed replies.
  • Exercises a malformed-JSON block split across multiple stream deltas with tools enabled.
  • Verifies the complete block is emitted once as text, produces no tool-call part, and contributes to the full reply text.
src/core/llm/providers/__tests__/cli-providers-subprocess.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T02:37:13.591337Z 91ba36d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: framerslab/agentos/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Team
  • Run ID: cb914b5e-a7e8-470f-8fbf-752648d73d99


📥 Commits

Reviewing files that changed from the base of the PR and between 48d82bb and 91ba36d.



📒 Files selected for processing (3)
  • docs/getting-started/CLI_PROVIDERS.md
  • src/core/llm/providers/__tests__/cli-providers-subprocess.test.ts
  • src/core/llm/providers/implementations/GeminiCLIProvider.ts


Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.




📝 Walkthrough
📝 Walkthrough

Walkthrough

The change clarifies Gemini CLI streaming behavior for <tool_call> blocks with invalid JSON, updates provider documentation, and adds a subprocess test that checks the block is emitted as text.

Changes

Gemini CLI streaming

Layer / File(s) Summary
Streaming behavior and coverage
src/core/llm/providers/implementations/GeminiCLIProvider.ts, src/core/llm/providers/__tests__/cli-providers-subprocess.test.ts, docs/getting-started/CLI_PROVIDERS.md
The provider comment and documentation state that blocks with non-JSON bodies stream as text. The comment also describes held-text handling for successful, failed, and aborted runs. The test checks that a malformed block and surrounding prose appear as text, with no tool-call part.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~4 minutes

Change: Other



Merge Risk: ⚪ Minimal · up to 91ba3

The change documents and tests the existing behavior that invalid-JSON tool-call blocks stream as text. No actionable merge risk is apparent; normal CI checks remain appropriate.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly identifies the documentation change and the Gemini CLI behavior for non-JSON tool-call blocks. It uses a valid Conventional Commits prefix.
Description check Passed The description covers the summary, linked issue, change types, verification details, migration notes, and checklist. It explains the changed behavior and the added test.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR



🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR



  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Clarify Gemini CLI streaming of non-JSON tool-call blocks

📝 Documentation 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Clarify that Gemini CLI excludes only recognized tool calls from streamed text.
• Document that blocks with non-JSON bodies stream as text instead.
• Add a streaming regression test for a non-JSON block split across deltas.
Diagram

graph TD
  A["CLI deltas"] --> B["Markup filter"] --> C{"Parsed tool call?"} -- "No" --> D["Text parts"] --> F["streamText consumer"]
  C -- "Yes" --> E["Final tool calls"] --> F
Loading
High-Level Assessment

Clarifying the documented contract and testing it through the existing streaming harness is appropriate. Changing provider behavior would be unnecessary because the filter already passes non-JSON blocks through as text.

Files changed (3) +24 / -9

Tests (1) +14 / -0
cli-providers-subprocess.test.tsTest streaming of a split non-JSON tool-call block +14/-0

Test streaming of a split non-JSON tool-call block

• A test streams a non-JSON block across multiple CLI deltas with prose on either side. It verifies the complete block appears once as a text part, produces no tool call, and remains in the assembled text.

src/core/llm/providers/tests/cli-providers-subprocess.test.ts

Documentation (2) +10 / -9
CLI_PROVIDERS.mdClarify which Gemini CLI blocks are excluded from streamed text +1/-1

Clarify which Gemini CLI blocks are excluded from streamed text

• The streaming guide now distinguishes recognized tool calls from blocks whose bodies are not JSON. It states that the latter stream as text rather than arriving as final tool calls.

docs/getting-started/CLI_PROVIDERS.md

GeminiCLIProvider.tsCorrect the streaming method’s tool-call documentation +9/-8

Correct the streaming method’s tool-call documentation

• The method’s JSDoc now says only blocks parsed as tool calls are omitted from streamed text. It explicitly notes that a block with a non-JSON body streams as text; provider logic is unchanged.

src/core/llm/providers/implementations/GeminiCLIProvider.ts

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can commit Qodo's fix in one click with committable suggestions (GitHub & GitLab)

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@jddunn
jddunn merged commit 76c0fe7 into master Oct 12, 2026
11 checks passed
@jddunn
jddunn deleted the docs/gemini-cli-non-json-block branch October 12, 2026 02:40
github-actions Bot pushed a commit that referenced this pull request Oct 12, 2026
## [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))
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