Skip to content

fix(confirmation): derive approval type from AI SDK ToolUIPart - #488

Open
ShobhanKarthish wants to merge 1 commit into
vercel:mainfrom
ShobhanKarthish:fix/confirmation-approval-type
Open

fix(confirmation): derive approval type from AI SDK ToolUIPart#488
ShobhanKarthish wants to merge 1 commit into
vercel:mainfrom
ShobhanKarthish:fix/confirmation-approval-type

Conversation

@ShobhanKarthish

Copy link
Copy Markdown

Summary

  • Replace the hand-copied ToolUIPartApproval union in confirmation.tsx with NonNullable<ToolUIPart['approval']> so the Confirmation approval shape stays aligned with the AI SDK.
  • Render approval.requestReason in ConfirmationRequest when that field is present, so explanations for why a tool call needs human review are visible without casting.
  • Add a unit test covering requestReason rendering.

Closes #484

Test plan

  • vitest run __tests__/confirmation.test.tsx (18 tests passed)
  • Confirm Confirmation request/accepted/rejected examples still render as before when requestReason is absent
  • With an approval object that includes requestReason, confirm the reason appears in the request UI

Replace the hand-copied ToolUIPartApproval union with
NonNullable<ToolUIPart['approval']> so the Confirmation component
stays aligned with the SDK. Surface approval.requestReason in
ConfirmationRequest when the field is present.

Closes vercel#484
@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@ShobhanKarthish is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.


export const ConfirmationRequest = ({ children }: ConfirmationRequestProps) => {
const { state } = useConfirmation();
const { approval, state } = useConfirmation();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConfirmationRequest's requestReason rendering is dead code because the pinned ai v6 dependency never emits a requestReason field on the approval-requested approval object.

Fix on Vercel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confirmation's approval type is a hand copy of the SDK's, and it has now drifted

1 participant