umanggarg Claude Sonnet 4.6 commited on
Commit
c0d33e7
·
1 Parent(s): 2c1c5eb

fix: parallel tool results matched in FIFO order, not reverse

Browse files

Scanning backwards filled the last empty slot first, so when the agent
called search_symbol three times in parallel the first result landed in
the third slot and vice versa. Results arrive in the same order as calls
(backend uses zip), so forward scan is always correct.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. ui/src/App.jsx +4 -2
ui/src/App.jsx CHANGED
@@ -499,8 +499,10 @@ export default function App() {
499
  prev.map((m) => {
500
  if (m.id !== assistantId) return m;
501
  const calls = [...m.toolCalls];
502
- // Find last call for this tool (most recent) and fill its output
503
- for (let i = calls.length - 1; i >= 0; i--) {
 
 
504
  if (calls[i].tool === tool && !calls[i].output) {
505
  calls[i] = { ...calls[i], output };
506
  break;
 
499
  prev.map((m) => {
500
  if (m.id !== assistantId) return m;
501
  const calls = [...m.toolCalls];
502
+ // Find the first (oldest) unfilled slot for this tool results arrive
503
+ // in the same order as calls were emitted, so FIFO matching is correct.
504
+ // Scanning backwards was wrong: parallel same-name calls got swapped.
505
+ for (let i = 0; i < calls.length; i++) {
506
  if (calls[i].tool === tool && !calls[i].output) {
507
  calls[i] = { ...calls[i], output };
508
  break;