Approve
Human-in-the-loop confirmation.
Purpose
Require user approval for sensitive actions — tool execution, content generation, deletions.
Use <approve> whenever a model or workflow is about to cross a policy boundary that should remain explicitly human-controlled.
Try it Live
editor.g
12345678910111213141516171819
Edit the Grain document and inspect the rendered preview beside it.
preview
Interactive preview initializes after hydration.
Interactive preview initializes after hydration. Open the docs preview at
/grain/; the site is mounted under the project base path. G-Lang
grain
<approve type="tool_call" action="Send email to user@example.com"
warning="This will send an external email">
<option label="Cancel"></option>
<option label="Send Email"></option>
</approve>Attributes
| Attribute | Type | Description |
|---|---|---|
type | tool_call | action | delete | consent | Approval type |
action | string | What needs approval |
warning | string | Warning message |
timeout | number | Auto-expire (ms) |
auto | true | false | Auto-approve |
Nested Elements
<option> — Approval options
grain
<option label="Cancel"></option>
<option label="Confirm"></option>
<option label="Confirm" primary></option>States
PENDING → SHOWING → APPROVED
↓ ↓ ↓
EXPIRED DENIED EXECUTING → COMPLETEEvents
| Event | Description |
|---|---|
approve.request | Approval requested |
approve.show | User saw request |
approve.approve | User approved |
approve.deny | User denied |
approve.expire | Request timed out |
Examples
Tool call approval
grain
<tool name="send_email" status="pending" mode="manual">
<input>To: user@example.com</input>
</tool>
<approve type="tool_call" action="Send email to user@example.com"
warning="This will send an email to an external address">
<option label="Cancel"></option>
<option label="Send Email"></option>
</approve>Delete confirmation
grain
<approve type="delete" action="Delete file: config.yaml"
warning="This action cannot be undone">
<option label="Keep File"></option>
<option label="Delete Forever"></option>
</approve>Consent request
grain
<approve type="consent" action="Share data with third party"
warning="Your data will be shared with our analytics partner">
<option label="Decline"></option>
<option label="Agree"></option>
</approve>With timeout
grain
<approve type="action" action="Apply changes" timeout="30000">
<option label="Cancel"></option>
<option label="Apply"></option>
</approve>Related
- Tool — Tool execution
- Error — Error handling
- Playground — Try it live
Operational Guidance
- Put the risky action in
actionand the user-facing caution inwarning. - Use
<option>labels that match the real decision, not vague placeholders. - Keep approval checkpoints explicit even if the surrounding tool run is otherwise automated.