fix(ai-chat): emit output-denied state for rejected tool approvals#956
fix(ai-chat): emit output-denied state for rejected tool approvals#956whoiskatrin wants to merge 3 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 66d2ddc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
|
/bonk review this PR |
Co-authored-by: whoiskatrin <whoiskatrin@users.noreply.github.com>
|
All 173 tests pass, including all 22 test files. Here's my review: PR Review: fix(ai-chat): emit output-denied state for rejected tool approvalsVerdict: Approve -- this is a clean, well-scoped bug fix with good test coverage. SummaryThe core change is a one-line fix at Code review
The fix itself is minimal and correct: state: approved ? "approval-responded" : "output-denied",
Changeset is well-written and scoped to
Escapes Minor observations (non-blocking)
VerdictClean fix, correct logic, good tests. Ship it. |
Summary
Fixes #955.
When
CF_AGENT_TOOL_APPROVALis sent withapproved: false,AIChatAgentnow transitions tool parts tooutput-denied(instead ofapproval-responded).This aligns with AI SDK expectations so
convertToModelMessagescan emit atool_resultfor denied approvals (required by Anthropic tool-use sequencing).What changed
packages/ai-chat/src/index.ts_applyToolApproval()now sets:approved: true->approval-respondedapproved: false->output-deniedapprovalobject to preserveapproval.id.packages/ai-chat/src/tests/client-tool-duplicate-message.test.tsoutput-denied.approval-requestedstate also transitions tooutput-deniedand preservesapproval.id.@cloudflare/ai-chatpatch release.Reviewer guide (quick pass)
_applyToolApprovalinpackages/ai-chat/src/index.ts.CF_AGENT_TOOL_APPROVAL handles rejection (approved: false)CF_AGENT_TOOL_APPROVAL with approved: false and autoContinue does NOT continueCF_AGENT_TOOL_APPROVAL rejection from approval-requested sets output-deniedValidation
npm run test:workers --workspace @cloudflare/ai-chat -- src/tests/client-tool-duplicate-message.test.ts -t "rejection|approved: false"