Files
Jack Sun 9ae753b5a4 fix(tools): Add proper cleanup for AgentTool to prevent MCP session errors
Clean up runner resources in AgentTool after sub-agent execution to ensure
MCP sessions are closed in the correct async task context. Without this fix,
MCP sessions were cleaned up during garbage collection in a different task,
causing "Attempted to exit cancel scope in a different task" errors.

This fix ensures that `runner.close()` is called immediately after the
sub-agent finishes executing, properly closing all MCP sessions and other
resources within the same async task context they were created in.

Also adds two demo agents showing how to use AgentTool with MCP tools:
- mcp_in_agent_tool_remote: Uses SSE mode (remote server connection)
- mcp_in_agent_tool_stdio: Uses stdio mode (local subprocess)

Both demos use Gemini 2.5 Flash and include zero-installation setup using uvx.

Related: #1112, #929
2025-11-05 14:09:43 -08:00
..
2025-11-03 13:33:53 -08:00