Fix stop button responsiveness and shutdown CancelledError
Agent loop (_execute_tools_with_sink):
- Poll stop_event every 1s while draining the event sink via asyncio.wait_for
- When stopped, cancel the tool task, yield a synthetic ToolEvent failure,
  append a cancellation message to session, yield StreamStopped, and return
- Pass stop_event into _execute_tools_with_sink call site

Subagent runner:
- Check stop_event at the start of each tool in turn_tool_calls loop
- Returns early with ("", False) when stopped mid-batch

McpManager.disconnect_all():
- Disconnect clients sequentially instead of asyncio.gather
- Handle asyncio.CancelledError per-client to avoid shutdown traceback

AppContainer.shutdown():
- Catch BaseException instead of Exception for MCP and DB cleanup

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent e04b4ca commit 7ac12f724c5633d3d07082e571d3d86473d1a0bc
@Eugene Sukhodolskiy Eugene Sukhodolskiy authored on 21 May
Showing 4 changed files
View
navi/core/agent.py
View
navi/core/container.py
View
navi/core/subagent_runner.py
View
navi/mcp/manager.py