You've already forked adk-python
mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
9ae753b5a4
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