Fix: tool events colliding across agents and status regression on replay#661
Open
hellop11 wants to merge 1 commit into
Open
Fix: tool events colliding across agents and status regression on replay#661hellop11 wants to merge 1 commit into
hellop11 wants to merge 1 commit into
Conversation
Contributor
Greptile SummaryThis PR fixes tool event tracking in the TUI live view. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "Fix tool events colliding across agents ..." | Re-trigger Greptile |
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.
Problem
test_directory_size_skips_symlinks in tests/test_live_view.py could fail when multiple agents were active in the same session because TuiLiveView tracked tool call/output events using a dictionary keyed only by call_id.
This caused two issues:
Tool events could collide across agents. If two agents reused the same call_id, one agent's event could overwrite the other's, causing incorrect or missing tool events in the timeline.
Replayed tool-call events could regress completed tools back to running. When _record_tool_call_data() was called again for an existing event, it always reset the status to running, even if _record_tool_output_data() had already marked the tool as completed or failed.
Fixes #660
Fix
Change the event lookup key from call_id to (agent_id, call_id) so tool events are isolated per agent.
Update _record_tool_call_data() so that, when an event already exists, it only refreshes mutable fields such as tool_name and args. The status and result fields are preserved and continue to be managed exclusively by _record_tool_output_data().
Changes
strix/interface/tui/live_view.py: key tool event lookup by (agent_id, call_id) instead of call_id.
strix/interface/tui/live_view.py: preserve existing status and result when replaying tool-call events.
tests/test_live_view.py: add three regression tests:
test_same_call_id_different_agents_stay_isolated
test_replayed_tool_call_does_not_regress_completed_status
test_failed_result_keeps_failed_status_after_replay
Before / After
Before: Tool events from different agents could overwrite each other when they shared the same call_id, and replayed tool-call events could incorrectly change a completed or failed tool back to running.
After: Tool events remain isolated between agents by using (agent_id, call_id) as the lookup key, and replaying a tool-call event updates only mutable metadata without altering the tool's final status or result.