Skip to content

Fix mcp session teardown#5217

Closed
csanz91 wants to merge 4 commits intolivekit:mainfrom
csanz91:fix_mcp_session_teardown
Closed

Fix mcp session teardown#5217
csanz91 wants to merge 4 commits intolivekit:mainfrom
csanz91:fix_mcp_session_teardown

Conversation

@csanz91
Copy link
Copy Markdown
Contributor

@csanz91 csanz91 commented Mar 24, 2026

Keep MCP client enter and exit on the same dedicated lifecycle task so AnyIO cancel scopes are closed by their owner task.

This fixes #5212

csanz91 added 3 commits March 24, 2026 17:34
Keep MCP client enter and exit on the same dedicated lifecycle task so AnyIO cancel scopes are closed by their owner task.

Add regression coverage for session shutdown, agent handoff, and initialize retry behavior.
Cancel and await the MCP lifecycle task when setup is interrupted before readiness.

Add regression coverage for canceled MCP toolset setup so interrupted startup does not leak a background task or surface an unhandled exception later.
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

@longcw
Copy link
Copy Markdown
Contributor

longcw commented Mar 27, 2026

fixed in #5223

@longcw longcw closed this Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AgentSession.aclose() leaves the event loop hot when adding MCPs

2 participants