Skip to content

fix: Parallel tool results are serialized in completion order, silently breaking provider prompt caching#16578

Merged
lgrammel merged 2 commits into
mainfrom
bugfix/16567-2
Jul 2, 2026
Merged

fix: Parallel tool results are serialized in completion order, silently breaking provider prompt caching#16578
lgrammel merged 2 commits into
mainfrom
bugfix/16567-2

Conversation

@lgrammel

@lgrammel lgrammel commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Background

Parallel tool results could be serialized in nondeterministic completion order instead of assistant tool-call order, causing equivalent histories to produce byte-different prompts and miss provider prompt caches.

Summary

Updated toResponseMessages to record assistant tool-call order and stably sort emitted tool-result content by matching toolCallId, with unknown ids kept last.

Testing

Kept the focused regression test for parallel tool calls resolving out of order and made its assertion type-safe.

Related Issues

Fixes #16567

@lgrammel lgrammel merged commit ecfeb6f into main Jul 2, 2026
54 checks passed
@lgrammel lgrammel deleted the bugfix/16567-2 branch July 2, 2026 14:41
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
ai 7.0.12 github npm
@ai-sdk/alibaba 2.0.5 github npm
@ai-sdk/amazon-bedrock 5.0.9 github npm
@ai-sdk/angular 3.0.12 github npm
@ai-sdk/anthropic 4.0.6 github npm
@ai-sdk/assemblyai 3.0.4 github npm
@ai-sdk/azure 4.0.6 github npm
@ai-sdk/baseten 2.0.4 github npm
@ai-sdk/black-forest-labs 2.0.4 github npm
@ai-sdk/bytedance 2.0.5 github npm
@ai-sdk/cerebras 3.0.4 github npm
@ai-sdk/cohere 4.0.4 github npm
@ai-sdk/deepgram 3.0.4 github npm
@ai-sdk/deepinfra 3.0.4 github npm
@ai-sdk/deepseek 3.0.4 github npm
@ai-sdk/elevenlabs 3.0.5 github npm
@ai-sdk/fal 3.0.5 github npm
@ai-sdk/fireworks 3.0.5 github npm
@ai-sdk/gateway 4.0.9 github npm
@ai-sdk/gladia 3.0.4 github npm
@ai-sdk/google 4.0.7 github npm
@ai-sdk/google-vertex 5.0.9 github npm
@ai-sdk/groq 4.0.4 github npm
@ai-sdk/harness 1.0.15 github npm
@ai-sdk/harness-claude-code 1.0.15 github npm
@ai-sdk/harness-codex 1.0.16 github npm
@ai-sdk/harness-deepagents 1.0.14 github npm
@ai-sdk/harness-opencode 1.0.15 github npm
@ai-sdk/harness-pi 1.0.15 github npm
@ai-sdk/huggingface 2.0.4 github npm
@ai-sdk/hume 3.0.4 github npm
@ai-sdk/klingai 4.0.5 github npm
@ai-sdk/langchain 3.0.12 github npm
@ai-sdk/llamaindex 3.0.12 github npm
@ai-sdk/lmnt 3.0.4 github npm
@ai-sdk/luma 3.0.5 github npm
@ai-sdk/mcp 2.0.6 github npm
@ai-sdk/mistral 4.0.4 github npm
@ai-sdk/moonshotai 3.0.6 github npm
@ai-sdk/open-responses 2.0.4 github npm
@ai-sdk/openai 4.0.6 github npm
@ai-sdk/openai-compatible 3.0.4 github npm
@ai-sdk/otel 1.0.12 github npm
@ai-sdk/perplexity 4.0.5 github npm
@ai-sdk/policy-opa 1.0.12 github npm
@ai-sdk/prodia 2.0.5 github npm
@ai-sdk/provider-utils 5.0.4 github npm
@ai-sdk/quiverai 2.0.4 github npm
@ai-sdk/react 4.0.13 github npm
@ai-sdk/replicate 3.0.5 github npm
@ai-sdk/revai 3.0.4 github npm
@ai-sdk/rsc 3.0.12 github npm
@ai-sdk/sandbox-just-bash 1.0.15 github npm
@ai-sdk/sandbox-vercel 1.0.15 github npm
@ai-sdk/svelte 5.0.12 github npm
@ai-sdk/togetherai 3.0.5 github npm
@ai-sdk/tui 1.0.12 github npm
@ai-sdk/valibot 3.0.4 github npm
@ai-sdk/vercel 3.0.4 github npm
@ai-sdk/voyage 2.0.4 github npm
@ai-sdk/vue 4.0.12 github npm
@ai-sdk/workflow 1.0.12 github npm
@ai-sdk/workflow-harness 1.0.15 github npm
@ai-sdk/xai 4.0.5 github npm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parallel tool results are serialized in completion order, silently breaking provider prompt caching

2 participants