fix(agent): isolate MCP transport failures - #365
Conversation
gloryfromca
left a comment
There was a problem hiding this comment.
Blocking: the required diff-coverage gate fails at 79.31%; see the inline note.
Reviewed current head 399a1dfd011d against github/main (b6f3818ae579). I covered AGENTS.md and the Runtime glossary, the complete diff, the AgentLoop startup and shutdown callers through close_mcp(), MCP 1.27.0 transport/session task-group behavior, relevant cancellation-fix history, backward compatibility, and whether tests were weakened. No other blocker or plain error survived refutation: the per-server nested stack unwinds a failed transport/session initialization before iteration continues, keeps successful sessions owned by the existing outer stack, and preserves the public function/config behavior.
Verification:
uv run pytest tests/test_sandbox_unit.py -x -q- 70 passed.- The new isolation regression fails against
github/mainand passes on this head. - A stronger external-cancellation probe using an AnyIO task group propagated
CancelledErrorcorrectly. uv run ruff check raven/agent/tools/mcp.py tests/test_sandbox_unit.py- passed.git diff --checkand merge-tree checks - clean.- GitHub CI executed 6901 tests successfully (33 skipped, 13 deselected), then failed the required changed-line coverage gate.
gloryfromca
left a comment
There was a problem hiding this comment.
No blockers; this can merge as far as I am concerned.
Reviewed current head 404c4cf4b755 against github/main and the previously reviewed 399a1dfd011d. The new commit is test-only and directly resolves the prior coverage blocker with focused assertions for the SSE client/header path and unknown-transport skip; it does not weaken, skip, or replace the transport-failure tests. I rechecked the repository rules and Runtime terms, the complete diff, the existing AgentLoop ownership/lifecycle callers, relevant history, and backward compatibility. There is no production-code delta from the prior review and no new plain error survived refutation.
Verification:
uv run pytest tests/test_sandbox_unit.py -x -q --cov=raven --cov-branch --cov-report=json:/tmp/pr365-404c4cf4-coverage.json- 72 passed.- Project diff-coverage gate - 100.00% (29/29), required threshold 90%.
uv run ruff check raven/agent/tools/mcp.py tests/test_sandbox_unit.py- passed.git diff --checkand merge-tree checks - clean.- All GitHub checks are green, including the full unit and coverage job.
Summary
Prevent a failed MCP transport from cancelling the main agent turn during startup.
Keep each MCP transport and handshake in one lifecycle so SDK task-group failures unwind into ordinary per-server connection errors. Raven can then continue with the remaining MCP servers and enter the model loop.
Type
Verification
Relevant tests pass locally
Relevant lint / type checks pass locally
User-facing docs or screenshots are updated when needed
uv run pytest tests/test_sandbox_unit.py -x -q- 70 passed.uv run ruff check raven/agent/tools/mcp.py tests/test_sandbox_unit.py- passed.A real
raven agentturn returnedRAVEN_FIXED_OKafter two configured MCP servers failed authentication.Docs and screenshots are not needed because no user-facing contract changed.
Risk
The change only alters failure isolation during MCP initialization. Roll back the single fix commit if transport lifecycle behavior regresses.
Related Issues
N/A