Skip to content

fix: resolve parallel tool-call completions in FIFO order#115

Open
Mingye-Lu wants to merge 1 commit into
mainfrom
fix/tool-call-fifo-pairing
Open

fix: resolve parallel tool-call completions in FIFO order#115
Mingye-Lu wants to merge 1 commit into
mainfrom
fix/tool-call-fifo-pairing

Conversation

@Mingye-Lu

Copy link
Copy Markdown
Owner

Summary

  • Two locations (ReplTuiState::handle_tool_call_complete in crates/tui/src/repl_app/input_editor.rs and ChildTabPanel::apply_event's ToolCallComplete arm in crates/tui/src/child_tabs.rs) resolved live tool-call rows via .iter_mut().rev().find(...), which matches the last still-Running entry with a matching name (LIFO) instead of the first (FIFO) as the surrounding doc comment claims.
  • With two parallel same-name calls in flight (e.g. two navigate calls to different URLs, A started before B), A's completion would get attached to B's live row and vice versa, showing the wrong output/status next to the wrong tool-call line in the transcript.
  • Fix: drop .rev() in both locations so the first still-Running matching entry (in original insertion order) is resolved first, matching the documented FIFO intent. No behavior change for the common case of a single in-flight call per tool name.

Test plan

  • Added tool_call_complete_resolves_parallel_same_name_calls_fifo in crates/tui/src/repl_app/tests.rs, asserting the first-started navigate call is resolved by the first completion and the second stays Running.
  • Added test_tool_call_complete_resolves_parallel_same_name_calls_fifo in crates/tui/src/child_tabs.rs, same scenario through ChildTabPanel::apply_event.
  • cargo fmt -p acrawl-tui
  • cargo test -p acrawl-tui (all 169 tests pass)
  • cargo clippy -p acrawl-tui --all-targets -- -D warnings (clean)

handle_tool_call_complete and ChildTabPanel::apply_event both used
.iter_mut().rev().find(...)/.find_map(...) to locate the still-Running
live tool-call entry to resolve, which matches the LAST matching entry
in insertion order (LIFO) rather than the first (FIFO). When two
parallel calls to the same tool (e.g. two navigate calls to different
URLs) are in flight, their completions could get attached to the wrong
row, showing the wrong output/status next to the wrong tool-call line.

Drop .rev() in both locations so the first still-Running matching
entry is resolved first, matching the documented FIFO intent.
@Mingye-Lu

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 0c07f1fd74

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

1 participant