🐛 Bug Description
Summary: The Gemini CLI bridge crashes with Separator is not found and chunk exceed the limit errors when an MCP tool returns a large response (e.g., mcp_kubernetes_events_list).
Expected Behavior: Large MCP tool responses should be processed without crashing the Gemini CLI bridge.
Actual Behavior: asyncio.StreamReader.readline() raises asyncio.LimitOverrunError because a single NDJSON line exceeds the default 64 KB buffer limit.
🔄 Steps to Reproduce
- Start a session using the Gemini CLI bridge
- Trigger a tool call that returns a large response (e.g.,
mcp_kubernetes_events_list on a busy cluster)
- The bridge crashes with
Separator is not found / chunk exceed the limit
🌍 Environment
Component: Ambient Agentic Runner — Gemini CLI bridge
File: components/runners/ambient-runner/ambient_runner/bridges/gemini_cli/session.py
📋 Additional Context
Root Cause: In ambient_runner/bridges/gemini_cli/session.py, the asyncio.create_subprocess_exec() call uses Python's default StreamReader buffer limit of 64 KB. The Gemini CLI outputs NDJSON lines to stdout — when a single line exceeds 64 KB (common with large tool results), asyncio.StreamReader.readline() raises asyncio.LimitOverrunError.
Error Messages:
asyncio.LimitOverrunError: Separator is not found, and chunk exceed the limit
🔍 Possible Solution
Add limit=10 * 1024 * 1024 (10 MB) to the create_subprocess_exec() call in session.py (around line 149). One-line change:
self._process = await asyncio.create_subprocess_exec(
*cmd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
cwd=self._cwd,
env=env,
limit=10 * 1024 * 1024, # Default 64KB is too small for large MCP tool responses
)
✅ Acceptance Criteria
🏷️ Labels
- Priority: high
- Complexity: trivial
- Component: backend
🐛 Bug Description
Summary: The Gemini CLI bridge crashes with
Separator is not foundandchunk exceed the limiterrors when an MCP tool returns a large response (e.g.,mcp_kubernetes_events_list).Expected Behavior: Large MCP tool responses should be processed without crashing the Gemini CLI bridge.
Actual Behavior:
asyncio.StreamReader.readline()raisesasyncio.LimitOverrunErrorbecause a single NDJSON line exceeds the default 64 KB buffer limit.🔄 Steps to Reproduce
mcp_kubernetes_events_liston a busy cluster)Separator is not found/chunk exceed the limit🌍 Environment
Component: Ambient Agentic Runner — Gemini CLI bridge
File:
components/runners/ambient-runner/ambient_runner/bridges/gemini_cli/session.py📋 Additional Context
Root Cause: In
ambient_runner/bridges/gemini_cli/session.py, theasyncio.create_subprocess_exec()call uses Python's defaultStreamReaderbuffer limit of 64 KB. The Gemini CLI outputs NDJSON lines to stdout — when a single line exceeds 64 KB (common with large tool results),asyncio.StreamReader.readline()raisesasyncio.LimitOverrunError.Error Messages:
🔍 Possible Solution
Add
limit=10 * 1024 * 1024(10 MB) to thecreate_subprocess_exec()call insession.py(around line 149). One-line change:✅ Acceptance Criteria
🏷️ Labels