Skip to content

fix(xl-ai): Array.from on filtered iterator — tool calls never marked complete - #2934

Open
gitfromwildan wants to merge 1 commit into
TypeCellOS:mainfrom
gitfromwildan:fix/xl-ai-tool-call-values-filter
Open

fix(xl-ai): Array.from on filtered iterator — tool calls never marked complete#2934
gitfromwildan wants to merge 1 commit into
TypeCellOS:mainfrom
gitfromwildan:fix/xl-ai-tool-call-values-filter

Conversation

@gitfromwildan

@gitfromwildan gitfromwildan commented Jul 31, 2026

Copy link
Copy Markdown

Description

s.values() returns a MapIterator / SetIterator, not an array. Calling .filter() directly on an iterator throws TypeError: s.values(...).filter is not a function or silently fails depending on the runtime.

This causes all tool calls to never be detected as complete, meaning AI tool call suggestions never appear in the UI.

Fix

Move .filter() to after Array.from():

-const toolCalls = Array.from(
-    toolCallStreams.values().filter((data) => data.complete),
-);
+const toolCalls = Array.from(
+    toolCallStreams.values(),
+).filter((data) => data.complete);

Related

Fixes #2933

Testing

  • Existing tests should pass (built-in type check)
  • No behavioral change — this is a pure bugfix

Summary by CodeRabbit

  • Bug Fixes
    • Fixed tool-call processing so completed calls are correctly collected during AI response streaming.

… complete

s.values() returns a MapIterator/SetIterator, not an array. Calling
.filter() directly on an iterator throws TypeError or silently fails
depending on the runtime.

Move .filter() after Array.from() to fix tool call completion detection.

Fixes TypeCellOS#2933
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

@gitfromwildan is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The tool-call collection now converts map values to an array before filtering completed streams. This prevents iterator filter errors and preserves completed tool calls for result processing.

Changes

Tool-call completion

Layer / File(s) Summary
Materialize completed tool calls
packages/xl-ai/src/streamTool/vercelAiSdk/util/chatHandlers.ts
The code converts toolCallStreams.values() to an array before filtering entries with complete set to true.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Poem

I’m a rabbit in the stream,
Making tool calls fit the dream.
Values hop into an array,
Completed calls are safely there.
No iterator errors remain.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the bug and fix, but it omits most required template sections and provides only limited testing details. Use the repository template headings and add rationale, impact, testing evidence, checklist status, and any applicable screenshots or additional notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The change implements the required Array.from conversion before filtering iterator values, fixing issue #2933.
Out of Scope Changes check ✅ Passed The two-line change is limited to the linked issue and contains no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly identifies the xl-ai bugfix and the iterator conversion that restores tool-call completion detection.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gitfromwildan gitfromwildan changed the title fix(xl-ai): → tool calls never marked complete fix(xl-ai): Array.from on filtered iterator — tool calls never marked complete Jul 31, 2026
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.

xl-ai: Array.from called on filtered iterator — tool calls never marked complete

1 participant