Skip to main content
Audience: engineers running autonomous or AI-assisted agents (LLM tool-callers, RPA bots, copilots) in regulated or sensitive environments who need a policy gate in front of consequential actions — and a tamper-evident record of what was authorized, denied, or sent for human approval. This recipe is a concrete instance of the synchronous pre-execution pattern in Integration Patterns. The novelty here is what you put in the decision context: not a transaction, but a proposed agent action.

The scenario

Your agent decides it wants to do something — run a database query, write a file, call an external API, export a record, spend tokens. Before it actually performs the action, you intercept it at the decision boundary and ask MeshQu: is this action allowed under our agent-governance policy? The policy checks things like:
  • The action declares a target environment and action type (no unscoped actions).
  • The action’s risk score is within limits — high risk routes to human approval, critical risk is denied outright.
  • The action does not export PII without an audit justification.
  • External API calls and resource scopes are declared and within budget.
MeshQu returns a verdict; your agent runtime acts on it.
Mental model: MeshQu is the gate, not the guard. It tells your runtime ALLOW / REVIEW / DENY. Your runtime is what actually lets the tool call through, holds it for a human, or refuses it. A receipt is produced either way.
MeshQu does not intercept your agent’s tool calls for you. You call MeshQu before executing the action and you enforce the verdict. A DENY is a signal — your runtime must be the thing that declines to run the tool.

Decision boundary

The agent never reaches EXEC without passing through MeshQu evaluates. Your runtime owns EXEC, HOLD, and REFUSE.

Gate a low-risk action with evaluate

For the hot path — gating thousands of routine tool calls — use evaluate. It is stateless and stores nothing, so it is cheap to call on every action. Persist only the consequential ones with record (next section).
The response includes result.decision and a violations array explaining why — e.g. a missing environment field or a risk_score over the threshold. Feed the violation reason back to the agent so it can adjust or surface it to the operator.

Record a consequential action with record

For actions you must be able to prove later — a production write, a PII access, anything an auditor will ask about — use record. It evaluates and persists a signed receipt, and naming the agent in actor (with type: "automated") binds which agent requested the action into the receipt.
TypeScript
The idempotency_key makes a retried gate call safe — if the agent retries the same action, you get the original receipt back (is_new: false) instead of a second authorization. See Idempotency.

Closing the loop on a held action

When a REVIEW action is approved or rejected by a human, record what happened with a decision outcome so the audit trail shows not just the verdict but the human resolution:

Operational notes

  • Roll out a new agent rule safely — start it in shadow_mode. The engine evaluates it and surfaces what it would have denied as ALERT, but the verdict your runtime reads stays unaffected until you promote it. Essential when you cannot afford to wrongly block an agent mid-run. See Shadow Mode.
  • Fail-closed for production actions — if MeshQu is unreachable, a high-stakes agent action should default to refuse, not run. See the fail-open vs fail-closed guidance in Integration Patterns.
  • Page on critical denials — subscribe a webhook filtered to ai_action_gate at severity_min: critical to alert when an agent attempts a critical-risk or PII-export action.

Concept references