Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

fix: use ID-based lookup for parallel tool finalization - #11007

Closed
daniel-lxs wants to merge 1 commit into
mainfrom
fix/parallel-tool-call-rendering
Closed

fix: use ID-based lookup for parallel tool finalization#11007
daniel-lxs wants to merge 1 commit into
mainfrom
fix/parallel-tool-call-rendering

Conversation

@daniel-lxs

Copy link
Copy Markdown
Member

Summary

Replaces map-based index tracking with direct ID lookup when finalizing streaming tool calls. This prevents duplicate rendering of parallel tools by ensuring idempotent processing.

Problem

When parallel tools are called, they could sometimes be rendered twice because:

  1. Multiple code paths can finalize the same tool (finalization loop, sweep fix, pending updates)
  2. The streamingToolCallIndices map-based lookup could reference tools that were already processed

Solution

Use findIndex with partial === true check instead of streamingToolCallIndices.get(event.id):

  • Only match blocks that are still partial === true
  • If a tool was already finalized (partial = false), skip it
  • Works for both sequential and parallel tool calling modes

Changes

  • src/core/task/Task.ts: Replace map-based index lookup in finalization loop with ID-based lookup

Testing

All 40 related tests pass:

  • 10 duplicate-tool-use-ids tests ✓
  • 7 NativeToolCallParser tests ✓
  • 23 presentAssistantMessage tests ✓

Risk Assessment

Low risk - The change is targeted and defensive:

  • Only affects the tool finalization code path
  • Idempotent by design (skips already-finalized tools)
  • No changes to tool execution logic

Replaces map-based index tracking with direct ID lookup when finalizing
streaming tool calls. This prevents duplicate rendering of parallel tools
by ensuring idempotent processing.

Changes:
- Use findIndex with partial===true check instead of streamingToolCallIndices
- Skip already-finalized tools to eliminate race conditions
- Works for both sequential and parallel tool calling modes

The previous approach relied on streamingToolCallIndices map which could
become stale when multiple code paths (finalization loop, sweep fix,
pending updates) process the same tool, causing duplicate rendering.
@ghost

ghost commented Jan 27, 2026

Copy link
Copy Markdown

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The change is clean and addresses the duplicate rendering problem for parallel tools effectively. The ID-based lookup with partial === true check ensures idempotent processing.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@daniel-lxs daniel-lxs closed this Jan 27, 2026
@github-project-automation github-project-automation Bot moved this from New to Done in Roo Code Roadmap Jan 27, 2026
@github-project-automation github-project-automation Bot moved this from Triage to Done in Roo Code Roadmap Jan 27, 2026
@daniel-lxs
daniel-lxs deleted the fix/parallel-tool-call-rendering branch January 27, 2026 16:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant