WithActionPolicy. An agent without that option keeps today’s tool path.
Guardrails still check only text. They do not see tool arguments or tool results. See Guardrails.
What is checked
One action is one tool call from the model. That includes native tools, MCP tools, A2A tools, sub-agent delegation, retriever tools, and memory tools the model calls. The SDK does not treat its own memory recall, retriever prefetch, or model calls as actions. Each call is decided before authorization, approval, and execution. The model then sees a tool message for a call that did not run, and the run continues.
A policy error, a panic, a timeout, or a decision the SDK does not recognize becomes a deny. The run continues. A failure to sign or store the receipt stops the run with
agent.ErrActionPolicyUnavailable. There is no unsigned fallback.
Register
NewRuleSet takes the decision used when no rule matches. That default may be allow, deny, step up, or defer.
Forbidden rules are checked first, in the order you declare them. A match is always a deny, using that rule’s id and reason. Among the other rules, the highest priority wins. Two rules with the same priority and the same result use the earlier rule. Two rules with the same priority and different results defer the call.
On Temporal, the starter and the worker must register the same policy id, version, hash, agent id, and signing key id. Change the version when you change what a rule matches. The hash covers the policy id, version, default, and each rule’s id, class, priority, and result. It does not cover the matcher function.
An agent that has a policy rejects a sub-agent, at any depth, that does not have one. A parent without a policy may still delegate to a child that has one.
Arguments and labels
actionpolicy.Tool, Kind, HasLabel, SessionHasLabel, PriorTool, PriorPending, RequesterHasRole, and Unverified are the built-in matchers. And, Or, and Not combine them. ArgType, ArgRange, ArgPattern, ArgIn, and ArgNotIn match a dotted field of nested arguments.
A missing argument path is treated as missing context and the call is deferred. A value of the wrong type does not match.
A classifier adds labels. Tools maps a tool name to labels. A tool with no entry gets the unclassified labels, which default to restricted. Patterns add a label when the expression matches the arguments, and again when it matches the tool result. A classifier error does not deny the call.
A BeforeTool or BeforeRetrieve hook that changes the arguments is checked again. The tool runs only when that second check allows it. The model sees Action denied by policy on recheck: <reason> otherwise.
Receipts
The sink receives one signed decision before the tool runs and one signed outcome after. The run result does not contain those receipts.AgentRunResult.Actions is a summary: session id, ledger head, how many actions were recorded, how many were denied, how many were deferred, and the labels on the session.
VerifyLedger checks the signature, the hash chain, and that every decision has an outcome. VerifyAction checks one call’s decision and outcome pair.
Give the same conversation id on later runs and set SessionStore when a later run must continue the same ledger. Without a store, or without a conversation id, the session id is the run id and nothing is loaded or saved.
Identity and pauses
actionpolicy.WithRequester attaches the caller to the context you pass to Run or Stream. The agent reads it once. An IdentityVerifier may replace that caller, including roles. The verifier’s error fails the run before it starts, as agent.ErrIdentityUnverified. RequireVerifiedIdentity returns the same error when the caller is missing or Verified is false. A delegated run keeps the caller’s identity and does not verify it again.
A step up uses the approval you already handle with AgentStream.Approve. A deferral uses AgentStream.Resolve. Approve on a deferral token records a human decision. A deferral has its own timeout (DeferTimeout, or the approval timeout when that is zero) and a per-run limit (MaxDeferrals, default 8). A deferral past that limit is a deny and does not pause.
Errors
errors.Is matches these sentinels on the local, Temporal, and Restate runtimes. ErrSessionConflict means the stored ledger moved between the load and the save. It is not ErrActionPolicyUnavailable.