You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Think: pruneMessages is too agressive "before-last-2-messages", breaks client-side tool workflows #1455
Client-side tool outputs (tools without execute — user provides output via addToolOutput) lose context after just 5 messages. The AI has zero memory of what the user chose and starts the flow
from scratch.
Verified in both @cloudflare/[email protected] and @0.5.3 (latest). There is no subclass hook to configure the pruning options.
With 5 UIMessages → ~7 model messages, all tool-call and tool-result parts from earlier tools get stripped. For client-side tools, user decisions (e.g., clarification answers, setup config) live only in those tool-result messages — so they're permanently lost.
Why client-side tools are uniquely affected
Server-side tools (with execute) resolve in the same turn — their results are always in the last 2 model messages and survive pruning. Client-side tools span multiple turns by design (LLM
proposes → user provides output → auto-continuation), so their results naturally fall outside the 2-message window on any follow-up message.
Reproduction
Define 2+ client-side tools (no execute)
User sends a message → AI calls tool 1 → user provides output via addToolOutput → AI auto-continues → calls tool 2 → user provides output → AI auto-continues
User sends any follow-up text message
AI has no memory of tool 1 or tool 2 outputs
Expected behavior
Tool results from client-side tools should not be silently stripped from a 5-message conversation.
Current workaround
The only escape hatch is overriding messages via TurnConfig in beforeTurn, but ctx.messages is already pruned at that point, so you have to rebuild from this.messages
In the client, we send the user answers as separate user messages so they stay in the conversation
Keep adding to context blocks, but context blocks feel like they're designed for high-signal, long-term facts — "this project uses Python 3.12. and the user always uses Mac."
changed the title [-]Think: pruneMessages with toolCalls: "before-last-2-messages" is hardcoded in _runInferenceLoop, breaks client-side tool workflows[/-][+]Think: pruneMessages is too agressive "before-last-2-messages", breaks client-side tool workflows[/+]on May 4, 2026
Activity
[-]Think: pruneMessages with toolCalls: "before-last-2-messages" is hardcoded in _runInferenceLoop, breaks client-side tool workflows[/-][+]Think: pruneMessages is too agressive "before-last-2-messages", breaks client-side tool workflows[/+]Remove default pruneMessages call from Think
Remove default pruneMessages call from Think (#1456)