-
Notifications
You must be signed in to change notification settings - Fork 331
Open
Description
Description
When using needsApproval on tools, duplicate assistant messages are created. The original message remains with input-available state while a new message is created with approval-responded state.
Reproduction
- Define a tool with
needsApproval: true - User triggers the tool
- User approves the tool call via
addToolApprovalResponse - Two assistant messages are persisted with the same
toolCallId
Persisted data showing the issue
{
"id": "assistant_1768917665170_4mub00d32",
"role": "assistant",
"parts": [{
"type": "tool-getJiraMyself",
"toolCallId": "d663825fd",
"state": "input-available",
"input": {}
}]
},
{
"id": "oFwQwEpvLd8f1Gwd",
"role": "assistant",
"parts": [{
"type": "tool-getJiraMyself",
"toolCallId": "d663825fd",
"state": "approval-responded",
"input": {},
"approval": { "id": "aitxt-xxx", "approved": true }
}]
}Observed behavior
- Server creates message with server-generated ID (
assistant_xxxformat), stateinput-available - After user approves, a second message is created with client-generated ID (
oFwQwEpvLd8f1Gwdformat), stateapproval-responded - The original message is never updated - it stays with
input-availablestate - Both messages have the same
toolCallId
Expected behavior
The original message should be updated to approval-responded state, not create a duplicate.
Environment
@cloudflare/ai-chat: 0.0.3agents: 0.3.3ai: 6.0.12
Metadata
Metadata
Assignees
Labels
No labels