Skip to content

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 ​

AttributeTypeDescription
typetool_call | action | delete | consentApproval type
actionstringWhat needs approval
warningstringWarning message
timeoutnumberAuto-expire (ms)
autotrue | falseAuto-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 → COMPLETE

Events ​

EventDescription
approve.requestApproval requested
approve.showUser saw request
approve.approveUser approved
approve.denyUser denied
approve.expireRequest 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>
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>

Operational Guidance ​

  • Put the risky action in action and the user-facing caution in warning.
  • Use <option> labels that match the real decision, not vague placeholders.
  • Keep approval checkpoints explicit even if the surrounding tool run is otherwise automated.

Released under the MIT License.