Skip to Content
AgentShield
Fundamentals

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:

FieldValue
payload_hashSHA-256 of the exact raw body of the authorize request
authorization_decision_idThe decision it belongs to
agent_idThe agent that asked
expires_at15 minutes after creation
statuspending

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/approvals is 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.decided event 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

StatusMeaningExecute result
pendingWaiting for a person409 approval_required
approvedReleased, not yet usedRuns once, then consumed
rejectedA person declined409 conflict
expired15 minutes passed without a decision409 approval_expired while the row still reads pending; 409 conflict once the control plane has marked it expired
consumedUsed by one executionRepeat 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 / callTool raise ApprovalRequired with the decision, including approval_id and approval_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_approval outcome 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.

Was this page helpful?

On this page