Repository navigation
fix(mcp): contain malformed tool results - #4666
Conversation
|
yours is way better :) |
maintainer edit: treat transient MCP stream failures as dead sessions so the existing reconnect handler can refresh the session before retrying. Also cover retry failure as a structured tool error.
|
Maintainer edit pushed: transient MCP stream failures such as closed streams now use the existing reconnect handler before retrying, so a stale MCP session can be refreshed without requiring a process restart. I also added regression coverage for reconnect success and retry failure returning a structured tool error. |
maintainer edit: update the existing transient retry tests for reconnect-first behavior and keep structured retry-failure coverage in the focused MCP transient suite.
|
Follow-up pushed: aligned the existing transient retry regression test with the reconnect-first behavior, and kept retry-exhaustion covered as a structured ToolResult.error. GitHub Actions are now green on the latest head. |
Re-bin
left a comment
There was a problem hiding this comment.
LGTM. This fixes the MCP tool-result failure path cleanly: malformed MCP content, timeouts, cancellations, and retry exhaustion now surface as structured tool errors instead of successful-looking text. The reconnect follow-up also keeps transient closed-stream failures on the existing MCP recovery path.
Validated locally:
- python -m pytest tests/tools/test_mcp_tool.py tests/agent/test_mcp_transient_retry.py -q
- python -m ruff check nanobot/agent/tools/mcp.py tests/agent/test_mcp_transient_retry.py tests/tools/test_mcp_tool.py
GitHub Actions is green across the matrix.
fix #4652
Summary
Changes
ToolResult.errorToolResult.errorCancelledErrorsignals