agentscope-ai / agentscope-ai/QwenPaw
[Feature]: MCP streamable_http session terminated — no auto-reconnect, client permanently skipped
- Dominant language
- Python
- Stars
- 34.9k
- Forks
- 3.1k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 225
Description
## Bug Description
When a `streamable_http` MCP session is terminated (e.g., MCP server restarts, network blip, or session timeout), QwenPaw fails to re-register the MCP client and skips it entirely for the rest of the session. There is no automatic reconnection attempt.
## Error
```
16:53:16 | WARNING | Failed to register MCP client "web-research-mcp", skipping: Session terminated
```
After this single failure, the MCP client is permanently skipped until QwenPaw is manually restarted.
## Reproduce Steps
1. Configure a `streamable_http` MCP client (e.g., web-research-mcp)
2. Verify it works: confirm tools are available
3. Restart the MCP server (or wait for session timeout)
4. Send a message to the agent that triggers the MCP
5. Observe: the MCP is skipped, no reconnection attempted
## Root Cause
In `stateful_client.py`, the MCP client list_tools call catches the exception and calls `register_mcp_clients` which skips the failing client. There is no retry/reinitialize logic:
```
File ".../qwenpaw/app/mcp/stateful_client.py", line 667, in list_tools
for mcp_tool in await mcp_client.list_tools():
File ".../qwenpaw/agents/react_agent.py", line 568, in register_mcp_clients
Failed to register MCP client "web-research-mcp", skipping: Session terminated
```
## Expected Behavior
When a previously-connected MCP session is terminated:
1. Automatically re-initialize (create new session) with the MCP server
2. Re-register the tools
3. Only disable the client if re-initialization also fails (e.g., server is actually down)
## Impact
- Any MCP server restart requires QwenPaw restart to recover
- If an MCP session expires during a long conversation, all tools from that MCP become unavailable
- Related to #4915 but different: #4915 handles "server unreachable", this handles "server reachable but session expired"
## Suggestion
In the MCP client lifecycle:
1. Catch `Session terminated` specifically (vs other errors)
2. Trigger a full re-initialize (new session) on next tool call
3. Add a retry limit (e.g., 3 attempts) before giving up
Contributor guide
Assessment
This issue has not been assessed yet.