Conversation
…fter room io The close event's handlers, the session host and room io closed after session_close and agent_session had ended, still in the session's context, so anything they emitted (a stall in a plugin's teardown, a handler's spans) parented to an ended span. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
session_closenow spans the whole ofAgentSession._aclose_locked: the activity teardown, thecloseevent's handlers, the session host and room io.agent_sessionends, and its root context is cleared, only after all of that.Why
The close span ended after the activity teardown, then
agent_sessionended, and the close event, session host and room io closed afterwards while the session's context was still current in the closing task. Anything emitted there parented to an already ended span. In a real export, a 103 msevent_loop_blockedfrom the ai_coustics enhancer's native free duringroom_io.aclose()showed up 8 ms afteragent_sessionhad closed, poking out of it.With this change that stall nests inside
session_close, where it happened, and aclosehandler's own spans do too.Tests
test_session_lifecycle_spans_and_eventsregisters aclosehandler that opens a span and asserts it nests undersession_close, thatsession_closeends after it andagent_sessionafter that, and that the root context is cleared.🤖 Generated with Claude Code