fix: human tool approval requests omit policy reasons (#19658)
## Background OPA documentation promises that `requires-approval` reasons reach human approvers, but published generation and UI approval requests omitted them. ## Root Cause The OPA normalizer discarded `requires-approval` reasons, while user-approval status and request types could not carry them; the original reproduction confirmed both `generateText` and `streamText` lost the reason. ## Summary - Preserved optional reasons through OPA normalization, approval status and request types, `generateText` and `streamText` outputs, response messages, UI serialization, processing, validation, and model-message conversion. - Kept the UI request reason as `approval.requestReason`, separate from the approver's response `reason`, so both survive approval state transitions and persisted-message round trips. - Documented the core result, UI message, stream protocol, and model-message conversion fields. - Added patch changesets for `ai`, `@ai-sdk/policy-opa`, and `@ai-sdk/provider-utils`. ## Compatibility Existing approval inputs and stored messages remain valid. Requests without a reason keep their previous runtime shape. The UI stream adds only an optional `reason` field, while UI messages add the optional `approval.requestReason` field and retain the existing response `approval.reason` semantics. ## Testing - Focused AI UI tests: 270 passed in Node and 270 passed in Edge. - Focused policy-OPA tests: 22 passed in Node and 22 passed in Edge. - Affected package type checks and the full workspace type check passed. - Formatting and lint checks passed with no warnings or errors. - Documentation content sync, MDX generation, and docs TypeScript checking passed. Regression coverage verifies OPA normalization and integration, `generateText`, `streamText`, response-message conversion, UI chunk conversion and processing, request/response reason lifecycle preservation, stored-message validation, public types, and model-message conversion. ## End-to-end Validation - `replay_original_reproduction`: both `generateText` and `streamText` human approval requests contained the policy reason; classified `no-longer-reproduces`. ## Related Issues Fixes #19654 Closes #19655 --------- Co-authored-by: ai-sdk-factory <308175966+ai-sdk-factory@users.noreply.github.com> Co-authored-by: ladanjohari <13539962+ladanjohari@users.noreply.github.com> Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
A
ai-sdk-factory[bot] committed
3e125bac1dd1f67be708741ac1f7b691909a3804
Parent: 48c5f46
Committed by GitHub <noreply@github.com>
on 8/26/2026, 7:00:39 PM