fix(session): preserve metadata in tool-call handler for subagent click navigation#20183
Closed
altendky wants to merge 2 commits intoanomalyco:devfrom
Closed
fix(session): preserve metadata in tool-call handler for subagent click navigation#20183altendky wants to merge 2 commits intoanomalyco:devfrom
altendky wants to merge 2 commits intoanomalyco:devfrom
Conversation
…ition This commit contains: 1. Fix for metadata callback to accept pending state (not just running) 2. Fix for processor.tool-call to preserve existing metadata from DB 3. Comprehensive diagnostic logging at all key points: - llm.ts: llm.queue.push for tool events - processor.ts: tool-input-start, tool-call, tool-call.existing, tool-result - prompt.ts: resolveTools.metadata, handleSubtask.metadata - task.ts: task.metadata.call The race condition: queue-based LLM layer decouples event processing from tool execution, causing ctx.metadata() to run before processor.tool-call transitions the part from pending to running. The fix reads current DB state in tool-call handler and preserves any existing metadata. Subagent click navigation now works. Separate issue observed: doom_loop permission triggered for task tool (needs investigation).
…ck navigation The queue-based LLM layer introduced a race condition: tool execute callbacks (which call ctx.metadata()) run before the processor's tool-call event handler transitions the part from pending to running. This caused metadata (including sessionId for subagents) to be silently dropped. Two fixes: 1. metadata callback now accepts pending state (not just running) 2. processor tool-call handler reads current DB state and preserves any existing title/metadata set by ctx.metadata() Fixes regression from c5442d4 (effectify SessionPrompt service).
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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.
Issue for this PR
Closes #20184
Type of change
What does this PR do?
Clicking on subagent labels in the TUI no longer navigated to the subagent session view after the effectify refactor. The issue was a race condition introduced by the queue-based LLM layer.
Root cause: The queue decouples event processing from tool execution. When a tool's
executecallback runs and callsctx.metadata()(to set the subagent's sessionId), the processor hasn't yet consumed thetool-callevent from the queue — so the part is still in "pending" state. The metadata callback had a guardif (status !== "running") returnwhich silently dropped the metadata.Additionally, even when metadata was successfully written to the DB, the processor's
tool-callhandler would overwrite it using stale in-memory state (ctx.toolcalls).Fix (two parts):
prompt.ts- Allow metadata updates for pending parts (only skip completed/error)processor.ts- Read current DB state before updating and preserve any existing title/metadataHow did you verify your code works?
matchStatus=pendingwhenctx.metadata()was calledScreenshots / recordings
N/A (behavioral fix, no UI changes)
Checklist