Repository navigation
fix(client): don't spread large result batches into splice when repairing tool result order - #3155
Merged
contextablemark merged 1 commit intoOct 22, 2026
Conversation
…ring tool result order
@ag-ui/a2a-middleware
@ag-ui/a2ui-middleware
@ag-ui/event-throttle-middleware
@ag-ui/mcp-apps-middleware
@ag-ui/mcp-middleware
@ag-ui/a2a
@ag-ui/adk-js
@ag-ui/adk
@ag-ui/ag2
@ag-ui/agno
@ag-ui/antigravity
@ag-ui/aws-strands
@ag-ui/claude-agent-sdk
@ag-ui/claude-managed-agents
@ag-ui/crewai
@ag-ui/langchain
@ag-ui/langgraph
@ag-ui/llamaindex
@ag-ui/mastra
@ag-ui/pydantic-ai
@ag-ui/vercel-ai-sdk
@ag-ui/watsonx
@ag-ui/a2ui-toolkit
create-ag-ui-app
@ag-ui/client
@ag-ui/core
@ag-ui/encoder
@ag-ui/proto
commit: |
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.
Fixes #3154
flushinkeepToolResultsWithCalls(sdks/typescript/packages/client/src/apply/default.ts) inserts the owed results withrepaired.splice(at, 0, ...owed.map(...)). Spreading a large batch intospliceexceeds the engine's argument limit, so a history with many detached results (150,000 in the issue) throwsRangeError: Maximum call stack size exceeded. This is a regression from #3143.The insertion now cuts off the short tail at
at(the reasoning/activity entries the owed results go in front of), pushes the owed results one by one, then pushes the tail back. The order is the same as before, without spreading into a call.Test:
moves a large batch of detached results without overflowing the call stackinsrc/apply/__tests__/default.snapshot-tool-order.test.ts(150,000 results, checks the order). It fails onmainwith theRangeErrorand passes with this change. The other tests in that file still pass. In my local run, the full client suite had 4 failures inesm-interop,cross-zod-copyandhttp-request-process, which depend on a full workspace build and network, not on this change.