Human Approvals
How require_approval holds a call for a person, how approvals are bound to the exact request, and how they are consumed exactly once.
Some actions should run only after a person agrees: refunds, outbound email, record updates. A policy expresses this by listing the action in approval_required. AgentShield then holds the call, shows it to an approver, and releases it once.
Lifecycle
Binding
When policy returns require_approval, the gateway inserts an approval_requests row in the decision's transaction:
| Field | Value |
|---|---|
payload_hash | SHA-256 of the exact raw body of the authorize request |
authorization_decision_id | The decision it belongs to |
agent_id | The agent that asked |
expires_at | 15 minutes after creation |
status | pending |
At execute, the approval must match the decision, the agent, and the payload hash stored with the execution when it was authorized. The agent cannot substitute a different request under an existing approval, and it cannot supply its own hash.
Who can decide
Only humans with the owner, admin, or approver role in the same organization can list, approve, or reject approvals. In addition:
- An agent credential cannot call the control plane at all.
- A user whose id equals the agent id cannot approve that agent's request (
403 self_approval). - Only the gateway creates approval rows.
POST /api/v1/approvalsis reserved in the contract and not registered, so no caller can mint an approval the gateway did not bind. - Approving or rejecting appends an
approval.decidedevent to the audit chain.
The approvals list includes what the approver needs to decide: the tool, operation, resource, redacted arguments, the request time, and the policy reason.
States
| Status | Meaning | Execute result |
|---|---|---|
pending | Waiting for a person | 409 approval_required |
approved | Released, not yet used | Runs once, then consumed |
rejected | A person declined | 409 conflict |
expired | 15 minutes passed without a decision | 409 approval_expired while the row still reads pending; 409 conflict once the control plane has marked it expired |
consumed | Used by one execution | Repeat execute returns the stored result |
A pending or approved row whose expires_at has passed is treated as expired at execute time. The control plane also marks stale pending rows expired when approvals are listed or decided, and an expired row cannot be approved.
Consumption
Consumption happens inside the execution claim transaction. The row is locked, checked, and updated to consumed only if it is still approved, unconsumed, and was decided by someone other than the agent. If the circuit is open, the whole claim rolls back, so the approval is not wasted.
A second execute of a completed call returns the stored result and does not consume another approval.
Waiting for approval in agents
call_tool/callToolraiseApprovalRequiredwith the decision, includingapproval_idandapproval_expires_at. Your code decides what to do next.- LangChain and CrewAI tools accept
approval_timeout(0–3600 seconds). With a timeout, the tool polls execute every two seconds until a person approves, rejects, or the approval expires, then returns a JSON result the model can read. - LangGraph node and MCP server return the
require_approvaloutcome immediately as a tool error.
For example, with http.post in the organization's approval_required list and api.github.com in the gateway's tools file:
from agentshield_sdk import ApprovalRequired
arguments = {"body": {"title": "Customer reported a broken export", "body": "Ticket 4821"}}
try:
client.call_tool(
tool_name="http.request",
operation="http.post",
resource="https://api.github.com/repos/octo/hello/issues",
arguments=arguments,
)
except ApprovalRequired as held:
decision = held.decision
print("approve in the console before", decision.approval_expires_at)
# Later, after a person approves:
result = client.execute(
decision.decision_id,
decision.idempotency_key,
approval_id=decision.approval_id,
arguments=arguments, # must hash to what was authorized
)Execute needs a registered adapter
Approval releases a call; it does not create an adapter for it. A tool with no adapter returns 501, and that response does not consume the approval.
Implementation references
Was this page helpful?