Bug fix: Gemini CLI bridge crashes on large MCP tool responses - raise gemini cli stream buffer limit to 10 MB#1242
Open
vishsanghishetty wants to merge 2 commits intoambient-code:mainfrom
Conversation
the default asyncio StreamReader limit of 64 KB causes crashes when an MCP tool returns a large response (e.g. kubernetes events list). closes ambient-code#1126 Signed-off-by: Vishali <vsanghis@redhat.com>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughSets the subprocess StreamReader buffer limit to 10 MB by passing Changes
🚥 Pre-merge checks | ✅ 7 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (7 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
spawns a real subprocess that outputs 100 KB on a single line and verifies readline() succeeds — would crash with the default 64 KB StreamReader limit. Signed-off-by: Vishali <vsanghis@redhat.com>
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
Raises the
asyncio.StreamReaderbuffer limit from the default 64 KB to 10 MB when spawning the Gemini CLI subprocess. Preventsasyncio.LimitOverrunErrorcrashes when an MCP tool (e.g.mcp_kubernetes_events_list) returns a large NDJSON line.Closes #1126
What changed
One-line fix in
session.py— addedlimit=10 * 1024 * 1024to theasyncio.create_subprocess_execcall.How I tested
Unit test —
test_stream_buffer_limit_raisedmockscreate_subprocess_execand asserts thelimitkwarg is10 * 1024 * 1024.Integration test —
test_large_stdout_line_does_not_crashspawns a real subprocess that outputs 100 KB on a single line (well above the old 64 KB default) and reads it with the 10 MB limit. This would crash withValueError: Separator is found, but chunk is longer than limitunder the old default. Passes with our fix.Full E2E reproduction (triggering an actual Gemini CLI session with a large MCP tool response) requires a running ACP instance with Gemini API keys, so that's not included here. The integration test proves the mechanism at the
asynciolevel.Summary by CodeRabbit
Bug Fixes
Tests