Repository navigation
Description
Summary
When an MCP synchronous call to an agent is dropped mid-execution (e.g., the MCP client times out or disconnects), the broken HTTP connection propagates as [Errno 32] Broken pipe inside the agent's Claude Code runtime. This single event triggers the circuit breaker, which stays open and accumulates failures from subsequent retries/polling on the still-running concurrent executions — eventually opening after 7+ failures and blocking all new task dispatches to the agent, even though the agent container is healthy and the other executions are still running successfully.
Component
Backend / Agent Client / Circuit Breaker / MCP Server
Priority
P2
Error
# Agent container log:
ERROR:agent_server.services.claude_code:[Headless Task] Execution error: [Errno 32] Broken pipe
# Backend log sequence:
ERROR services.task_execution_service: [TaskExecService] Failed to execute task on [AGENT]: Task execution error: [Errno 32] Broken pipe
WARNING services.agent_client: Circuit OPENED for agent [AGENT] after 3 failures
WARNING services.agent_client: Circuit OPENED for agent [AGENT] after 4 failures
WARNING services.agent_client: Circuit OPENED for agent [AGENT] after 5 failures
WARNING services.agent_client: Circuit OPENED for agent [AGENT] after 6 failures
WARNING services.agent_client: Circuit OPENED for agent [AGENT] after 7 failures
Timeline
- T+0: Agent is running 2 concurrent executions (slots 1/3 and 2/3)
- T+0: MCP sync call dispatches a 3rd task (slot 3/3)
- T+10s: MCP client connection drops; agent gets EPIPE writing response → HTTP 500
- T+60s onward: Concurrent running executions trigger probe/retry calls → circuit opens repeatedly
- Result: Agent healthy but circuit blocked, no new tasks accepted
Root Cause
Two interacting issues:
-
Broken pipe propagation: When the backend closes its HTTP connection to the agent (due to MCP client disconnect), the agent server gets
EPIPEtrying to write back. This is surfaced as a task execution error rather than a connection-level error, causing it to count against the circuit breaker failure threshold. -
Circuit breaker over-sensitivity: A single EPIPE from a dropped client connection (not an agent health issue) increments the circuit breaker failure counter. The subsequent concurrent executions' completion callbacks are then misinterpreted as additional failures, opening the circuit after only 3 real errors.
Reproduction Steps
- Start an agent with 2+ parallel slot capacity
- Start 2 long-running executions on the agent (filling 2 slots)
- Make an MCP synchronous call that dispatches a 3rd task to the same agent
- Drop/cancel the MCP client connection before the task completes
- Observe
[Errno 32] Broken pipeerror followed by circuit breaker opening - Observe the circuit continues to open on subsequent attempts even though the agent container is running fine
Suggested Fix
Two-pronged fix:
-
Distinguish connection errors from execution errors: In the agent client HTTP layer, catch
BrokenPipeError/ConnectionResetErrorand classify them as connection-level failures rather than execution failures. These should not count toward the circuit breaker threshold, or should count much less aggressively. -
Circuit breaker should not re-open on concurrent execution completions: After the initial EPIPE trip, the circuit breaker should not continue accumulating failures from the completion callbacks of the other still-running (healthy) executions. Consider resetting the circuit to half-open after the first recovery attempt rather than letting concurrent callbacks pile on.
Environment
- Trinity version:
615a266 - OS: Ubuntu 22.04
Related
- Circuit breaker implementation:
services/agent_client.py - MCP sync execution path
- Issue bug: MCP sync execution recorded as triggered_by=manual instead of mcp #473 (MCP sync attribution bug — same root call)
Activity
AndriiPasternak31 commentedon May 11, 2026
/claim
github-actions commentedon May 11, 2026
Claimed by @AndriiPasternak31. Label
status-in-progressadded.Next steps:
feature/474-<short-slug>Fixes #474docs(flows): sync agent-monitoring + AgentClient flows with #474 circ…
chore(tests): register test_circuit_breaker.py in registry (#474)
chore(tests): register integration circuit-breaker + monitoring tests (…
fix(circuit-breaker): only count TCP unreachability toward circuit (#474
docs(flows): sync agent-monitoring + AgentClient flows with #474 circ…
chore(tests): register test_circuit_breaker.py in registry (#474)
chore(tests): register integration circuit-breaker + monitoring tests (…
chore(tests): adopt _STUBBED_MODULE_NAMES helper in test_monitoring_s…
26 remaining items
fix(circuit-breaker): broaden TimeoutException + /health-timeout live…
test(qa): regression coverage for gemini_runtime pipe-drop 502 (#474)
docs(security): CSO --diff audit report for #474 follow-up commits
fix(circuit-breaker): drop-grace + pipe-drop reclassification — #474 …
Merge origin/dev into AndriiPasternak31/issue-678-plan
fix(#936): refresh stale test expectations for #665, #898, #474 (#940)
vybe commentedon Jun 1, 2026
Shipped in v0.6.0 (released via #998).
Release: v0.7.0 (#1319)
fix(workspace): the chat tab strip — a visible New chat, a Main that …