Bug: Tool approval continuation result not reaching frontend (think@0.7.3 + agents@0.13.3)
Environment
@cloudflare/think@0.7.3
agents@0.13.3
@cloudflare/ai-chat@0.7.2
Description
After a user approves a needsApproval tool, the tool executes successfully on the server, but the tool part state never transitions from approval-responded to output-available on the frontend. The UI permanently shows "Executing..." with a spinning indicator.
Related Issues
Steps to Reproduce
- Define a tool with
needsApproval: true
- User sends a message that triggers the tool
- Tool approval card appears, user clicks "Approve"
- Tool executes successfully on the server (verified via database state)
- Frontend tool part stays at
approval-responded state indefinitely
- UI shows spinning "Executing..." forever
- Only when user sends a NEXT message does
beforeTurn clean up the stale state
Expected Behavior
After approval, the continuation should:
- Execute the tool
- Update the tool part state to
output-available with the tool output
- Stream the result back to the frontend
- UI transitions from "Executing..." to "Complete" with output
Actual Behavior
- Server-side: Tool executes correctly, state changes persist
- Frontend: Tool part stays at
approval-responded, never receives output-available
- The continuation stream appears to not reach the frontend
WebSocket Evidence
After user approves the tool, the cf_agent_chat_messages broadcast shows the tool part stuck at:
{
"toolName": "updateTrigger",
"state": "approval-responded",
"approval": { "id": "...", "approved": true }
}
No subsequent cf_agent_message_updated or stream chunk updates the state to output-available.
Workaround
In our beforeTurn override, we clean up stale approval-responded parts on the next non-continuation turn. This means the state only resolves when the user sends another message, not immediately after approval.
Bug: Tool approval continuation result not reaching frontend (think@0.7.3 + agents@0.13.3)
Environment
@cloudflare/think@0.7.3agents@0.13.3@cloudflare/ai-chat@0.7.2Description
After a user approves a
needsApprovaltool, the tool executes successfully on the server, but the tool part state never transitions fromapproval-respondedtooutput-availableon the frontend. The UI permanently shows "Executing..." with a spinning indicator.Related Issues
addToolOutput/ client-tool auto-continuations don't attach to the response stream — delivered only as an end-of-turn replay #1586 — Fixed_scheduleAutoContinuation50ms coalesce race condition. Our issue persists after upgrading to the versions that include this fix.Steps to Reproduce
needsApproval: trueapproval-respondedstate indefinitelybeforeTurnclean up the stale stateExpected Behavior
After approval, the continuation should:
output-availablewith the tool outputActual Behavior
approval-responded, never receivesoutput-availableWebSocket Evidence
After user approves the tool, the
cf_agent_chat_messagesbroadcast shows the tool part stuck at:{ "toolName": "updateTrigger", "state": "approval-responded", "approval": { "id": "...", "approved": true } }No subsequent
cf_agent_message_updatedor stream chunk updates the state tooutput-available.Workaround
In our
beforeTurnoverride, we clean up staleapproval-respondedparts on the next non-continuation turn. This means the state only resolves when the user sends another message, not immediately after approval.