Skip to content

Bug: needsApproval tool approval-responded state never transitions to output-available (think@0.7.3 + agents@0.13.3) #1627

@powfan

Description

@powfan

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

  1. Define a tool with needsApproval: true
  2. User sends a message that triggers the tool
  3. Tool approval card appears, user clicks "Approve"
  4. Tool executes successfully on the server (verified via database state)
  5. Frontend tool part stays at approval-responded state indefinitely
  6. UI shows spinning "Executing..." forever
  7. Only when user sends a NEXT message does beforeTurn clean up the stale state

Expected Behavior

After approval, the continuation should:

  1. Execute the tool
  2. Update the tool part state to output-available with the tool output
  3. Stream the result back to the frontend
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions