fix(session): preserve tool metadata across pending→running transition#20187
Closed
rmk40 wants to merge 1 commit intoanomalyco:devfrom
Closed
fix(session): preserve tool metadata across pending→running transition#20187rmk40 wants to merge 1 commit intoanomalyco:devfrom
rmk40 wants to merge 1 commit intoanomalyco:devfrom
Conversation
Contributor
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Related PR Found
The current PR (#20187) appears to be a refined or follow-up fix to #20183, addressing the regression from the SessionPrompt effectify commit. |
058d701 to
0f8d2b9
Compare
The effectify refactor (c5442d4) introduced a race where ctx.metadata() fires before the processor's tool-call event transitions the part from pending to running. The tool-call handler constructs a fresh state without metadata, clobbering the sessionId the task tool just wrote. This made subagent sessions unclickable in the TUI while running. - Add toolMetadata side-channel on processor context - Metadata callback writes synchronously to the side-channel - tool-call handler merges pending metadata into running state - Clean up toolMetadata entries in tool-result and tool-error
0f8d2b9 to
00739a8
Compare
Contributor
Author
|
Superseded by a new PR that includes both the fix and an E2E regression test. |
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.
Summary
Regression from c5442d4 (effectify SessionPrompt): clicking a running subagent
in the TUI does nothing because
state.metadata.sessionIdis never populatedwhile the tool is running.
Root Cause
ctx.metadata({sessionId})fires while the part is stillpending. Theprocessor's
tool-callhandler then transitions the part torunningwith afresh state object — clobbering the metadata. The TUI reads
state.metadata.sessionIdfor click navigation, so it's always empty.Fix
Synchronous side-channel (
toolMetadatamap) on the processor context:setToolMetadata()writes immediately when the metadata callback firestool-callhandler mergestitle/metadatafrom the map into the running statetool-resultandtool-errorUses an in-memory side-channel rather than a DB read, so the metadata is
guaranteed to be available regardless of async scheduling.