This lesson covers the engineering of the two oversight mechanisms for agents: approval gates before consequential tool calls, and audit records after every one. It gives an event schema grounded in NIST SP 800-53’s AU family, explains where in the stack each event should be emitted and how to correlate them, shows a minimal tamper-evident log and its limits, and covers approval design informed by usable-security research. The examples are vendor-neutral.
Two mechanisms, one data model
An approval gate is a synchronous policy decision that blocks a specific tool call until a human returns allow or deny. An audit record is an immutable event describing an action, decision or state change. In a well-built system they share a data model: every approval request, decision and resulting tool call is an audit event, linked by identifiers, so that “who allowed this?” is a join rather than a forensic exercise.
OWASP’s LLM06 mitigations name both: require human approval for high-impact actions, and “log and monitor the activity of LLM extensions and downstream systems” [1]. The MCP specification adds that applications should show which tools are exposed, indicate visibly when tools are invoked, and present confirmation prompts so a human can deny invocations [2]. Chan et al. frame the broader governance case: agent identifiers, real-time monitoring and activity logging are the three categories of measures for visibility into AI agents, each with implementations that trade informativeness against intrusiveness and privacy [3].
What to record: the AU family applied to agents
NIST SP 800-53 Rev. 5 gives the baseline [4]:
- AU-2 Event Logging: decide which event types are logged, coordinate with whoever needs the data, and document why the selection is adequate “to support after-the-fact investigations of incidents”.
- AU-3 Content of Audit Records: each record establishes event type, time, location, source, outcome, and the identity of individuals, subjects or objects involved.
- AU-8 Time Stamps: use UTC or record the offset.
- AU-9 Protection of Audit Information: protect logs and logging tools from unauthorised access, modification and deletion, and alert on attempts; AU-9(4) restricts management of logging to a subset of privileged users.
- AU-10 Non-repudiation: evidence that an individual, or a process acting on behalf of an individual, performed an action.
- AU-11 Retention and AU-6 Review, Analysis and Reporting.
- AC-6(9): log the execution of privileged functions.
For agents, the event types worth logging (AU-2) are:
| Event type | Emitted by | Notes |
|---|---|---|
tool.call |
Gateway or host | Every invocation, with decision and outcome |
policy.decision |
Policy engine | allow, ask, deny, with the matching rule ID |
approval.requested / approval.decided |
Approval service | Include exactly what the approver was shown |
grant.created / grant.changed /
grant.revoked |
Authorisation service | Scope, duration, issuer, approver |
agent.config.changed |
Configuration store | Diff, author, reviewer |
tool.definitions.changed |
Host or gateway | Hash of old and new definitions per server |
content.ingested |
Host | Source and hash of untrusted content entering context |
credential.used |
Credential broker | Which secret was used for which destination, never its value |
The last two are the agent-specific additions.
content.ingested lets you answer “what did the agent read
just before it did that?”, which is the core question in indirect prompt
injection investigations [5].
tool.definitions.changed matters because tool poisoning
attacks place instructions in descriptions that clients show the model
but not the user [6].
A record schema
A vendor-neutral record that satisfies AU-3 and supports agent investigations:
{
"schema": "agent-audit/1",
"event_id": "01JCX3K8V5Q2P7ZB4N9Y6T1HRA",
"event_type": "tool.call",
"ts_utc": "2026-08-04T01:20:03.412Z",
"trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
"span_id": "00f067aa0ba902b7",
"agent": { "id": "ag-07", "name": "intake-sorter", "version": "2026.08.1",
"model": "provider/model-name@2026-07", "runtime": "host-x 4.2.0" },
"principal": { "type": "user", "id": "lee@southside.example" },
"on_behalf_of": { "type": "mailbox", "id": "intake@southside.example" },
"grant": { "id": "g-1932", "scopes": ["mail.send:internal", "mail.send:client"], "expires": "2026-08-04T09:00:00Z" },
"tool": { "server": "mail-mcp", "server_version": "1.8.3", "name": "send_message",
"definition_sha256": "9f2c…" },
"arguments": { "to": ["t.r@example.net"], "subject_sha256": "c1a0…", "body_sha256": "77d4…",
"attachments": 0 },
"policy": { "decision": "ask", "rule_id": "mail.send.client", "engine": "policy-svc 1.3" },
"approval": { "request_id": "apr-5521", "decided_by": "lee@southside.example",
"decision": "approve", "latency_ms": 418000, "display_sha256": "e3b9…" },
"outcome": { "status": "success", "resource_id": "msg-88213" },
"source": { "host": "agent-runner-2", "ip": "10.0.4.12" }
}Design notes:
- Identify the agent, the human principal and the authority separately. Several agents may act for one person, and one agent may act through a shared mailbox. Conflating them destroys attribution, which Shavit et al. single out as a practice for keeping agents accountable [7].
- Hash or redact content by default. Subject and body digests let you prove which message was sent (by hashing the stored copy) without duplicating client data into the audit store. Keep full content only where you have a justified need and an access control to match; ASD’s ACSC recommends prioritising protection of logs that “have a justified requirement to record sensitive data” [8].
- Record what the approver saw
(
display_sha256over the rendered approval). If the rendering omitted the external recipient, that is a design flaw the log should expose. - Pin versions: agent configuration, model identifier, server version and tool definition hash. Behaviour can change between versions with no configuration change.
- Never log secrets. Log token or grant identifiers
(
jti, grant ID), never token values.
Correlation across the stack
An agent action passes through several components: the host that runs
the model loop, a policy gateway or MCP proxy, the MCP server, and the
downstream API. Each should emit its own events, linked by a trace
context. The MCP 2026-07-28 revision documents conventions for
propagating OpenTelemetry trace context (traceparent,
tracestate, baggage) in request
_meta [9], and
OpenTelemetry’s generative AI conventions define spans such as
execute_tool with attributes including
gen_ai.tool.name and gen_ai.tool.call.id, plus
MCP-specific attributes such as mcp.method.name [10]. Tool call arguments and results are
opt-in attributes in those conventions because they may contain
sensitive data [10]. The conventions
are marked Development, so pin the version you emit.
Use tracing for operational debugging and a separate audit stream for evidence. Traces are typically sampled, mutable in retention and widely readable; audit records must be complete, retained to policy and access-controlled. Emit both from the same instrumentation point with the same IDs.
Making the log tamper-evident
AU-9 asks that audit information be protected from modification and deletion. Access control is the first layer: the agent’s credentials must not grant write or delete access to its own audit trail, and log management should be limited to a small set of administrators (AU-9(4)) [4]. Storage with object lock or write-once retention is the second.
The third layer is cryptographic tamper evidence. Schneier and Kelsey’s 1999 scheme makes log entries written before a machine’s compromise impossible for the attacker to read and impossible to alter undetectably [11]. The simplest practical form is a hash chain, where each entry commits to its predecessor:
# Minimal hash-chained audit log (illustrative; tested with Python 3.13)
import hashlib, hmac, json
from datetime import datetime, timezone
GENESIS = "0" * 64
def canonical(record: dict) -> bytes:
return json.dumps(record, sort_keys=True, separators=(",", ":")).encode()
def append(log: list[dict], event: dict, key: bytes) -> dict:
body = {
"seq": len(log),
"ts_utc": datetime.now(timezone.utc).isoformat(timespec="milliseconds").replace("+00:00", "Z"),
"prev_hash": log[-1]["entry_hash"] if log else GENESIS,
"event": event,
}
# The HMAC key belongs to the log service, never to the agent.
body["entry_hash"] = hmac.new(key, canonical(body), hashlib.sha256).hexdigest()
log.append(body)
return body
def verify(log: list[dict], key: bytes) -> int | None:
"""Index of the first bad entry, or None if the chain is intact."""
prev = GENESIS
for i, entry in enumerate(log):
body = {k: v for k, v in entry.items() if k != "entry_hash"}
expected = hmac.new(key, canonical(body), hashlib.sha256).hexdigest()
if entry["seq"] != i or entry["prev_hash"] != prev \
or not hmac.compare_digest(expected, entry["entry_hash"]):
return i
prev = entry["entry_hash"]
return NoneEditing any historical entry causes verify to return
that entry’s index. Know the limits:
- Truncation. Deleting the newest entries leaves a valid shorter chain. Periodically anchor the head hash somewhere the log operator cannot rewrite: a separate account, a signed checkpoint sent to a second party, or a public transparency log.
- Key compromise. Anyone holding the HMAC key can rebuild the whole chain. Keep the key in the log service, rotate it, and use signatures if third parties must verify.
- Linear audits. Verifying a hash chain is linear in its length. Crosby and Wallach describe tree-based tamper-evident logs in which the logger can prove both that an event is present and that the current log is consistent with an earlier view, with proofs of logarithmic size [12]. Certificate Transparency (RFC 6962) applies Merkle-tree audit paths and consistency proofs to public, append-only logs [13]. For most small deployments, a managed log store with immutability plus periodic signed checkpoints is adequate; Merkle structures matter when external parties need to audit you.
Approval gates: engineering for human limits
An approval gate is a human-in-the-loop control, and its failure mode is the human. Two lines of research set the design constraints.
Akhawe and Felt analysed more than 25 million in-browser warning impressions. Click-through ranged from about a tenth of Firefox’s malware and phishing warnings to 70.2% of Chrome’s SSL warnings at the time, which they read as showing that warning design has a significant effect on behaviour [14]. Parasuraman and Manzey’s review found automation bias produces both omission and commission errors, affects experts and novices, and “cannot be prevented by training or instructions” [15]. The combination means approval quality is mostly a property of the system, not the operator.
Engineering consequences:
- Gate on effect, not tool name. Approve
mail.sendto a new external domain; auto-allowmail.sendto a colleague if policy permits. Fewer, higher-stakes prompts keep attention. - Render the concrete effect. Recipients, attachments with their classification, diff, amount, destination URL, and the grant that will be used. Make the riskiest property visually prominent.
- Bind the approval to the exact request. Hash the canonical tool call and include the hash in the approval; reject execution if the call changes after approval. This prevents an agent (or an injected instruction) from obtaining approval for one thing and executing another.
- Expire and scope. One call, or a short window with a call budget. Long-lived approvals are grants and belong in the grant system with their own audit trail.
- Make deny the cheap path. Single action, no reason required, structured refusal returned to the agent.
- Measure. Log approval latency and approval rate per approver and per rule. A rule approved more than, say, 95% of the time with sub-second latency is not being read; either allow it with tighter conditions or deny it.
- Use step-up authorisation for privilege changes. The MCP project’s security guidance recommends starting with a minimal scope set, elevating via targeted scope challenges when a privileged operation is first attempted, and logging elevation events (scope requested, subset granted) with correlation IDs [16].
# Binding an approval to the exact tool call (illustrative)
import hashlib, json, time
def call_digest(tool: str, args: dict, grant_id: str) -> str:
payload = json.dumps({"tool": tool, "args": args, "grant": grant_id},
sort_keys=True, separators=(",", ":")).encode()
return hashlib.sha256(payload).hexdigest()
def execute_if_approved(tool, args, grant_id, approval, run):
if approval["decision"] != "approve":
raise PermissionError("denied by approver")
if approval["call_sha256"] != call_digest(tool, args, grant_id):
raise PermissionError("call changed after approval")
if approval["expires_epoch"] < time.time():
raise PermissionError("approval expired")
return run(tool, args)Retention and review
ASD’s ACSC and co-authors recommend a single trustworthy time source, UTC, ISO 8601 timestamps with millisecond precision where possible, centralised collection, TLS and cryptographic verification for log integrity in transit and at rest, and retention informed by risk, noting that it can take up to 18 months to discover an incident [8]. NIST SP 800-92 remains the general reference for log management infrastructure [17]. For agent audit trails, a reasonable default for a small organisation is 12 months hot or warm, longer in cold storage where regulation or contracts require it, with deletion on schedule because audit logs are themselves personal information.
Review (AU-6) should be partly automated. Useful standing queries:
-- Denials and asks by agent over the last 7 days
SELECT agent_id, policy_decision, COUNT(*) FROM agent_audit
WHERE ts_utc > now() - interval '7 days' GROUP BY 1, 2 ORDER BY 3 DESC;
-- First-seen external destinations (possible exfiltration)
SELECT a.agent_id, a.destination, MIN(a.ts_utc) AS first_seen
FROM agent_audit a
WHERE a.event_type = 'tool.call' AND a.destination IS NOT NULL
GROUP BY 1, 2 HAVING MIN(a.ts_utc) > now() - interval '1 day';
-- Approvals that were almost certainly not read
SELECT decided_by, rule_id, COUNT(*), percentile_cont(0.5) WITHIN GROUP (ORDER BY latency_ms)
FROM approvals WHERE ts_utc > now() - interval '30 days'
GROUP BY 1, 2 HAVING percentile_cont(0.5) WITHIN GROUP (ORDER BY latency_ms) < 1500;Don’t log the chain of thought as evidence
It is tempting to treat a model’s reasoning trace as the explanation of an action. Shavit et al. note that reasoning traces help users spot errors but that chain-of-thought transparency “cannot yet be fully relied on”, because models do not always rely on the reasoning they display [7]. Store reasoning traces as debugging context if your privacy settings allow, but base findings on actions, inputs and decisions.
Worked example: answering a client’s question
Southside Community Legal runs an intake agent with read and file
permissions Allowed, client email on Ask and deletion on Never. A client
asks whether the agent accessed or disclosed his information. Because
every tool call carries on_behalf_of, grant,
tool, hashed arguments and approval, the
coordinator queries by the client’s folder ID and email address across
tool.call and content.ingested, and finds
three events: one ingestion, one filing, one approved acknowledgement
with the approver’s identity and the rendered display hash. The hash
chain verifies, the head checkpoint matches the copy stored in the
centre’s separate archive account, and the answer can be given with
confidence. During the same review the approval latency query shows one
rule (internal calendar invites) approved 140 times in a month with a
median of 0.9 seconds; it is moved to Allowed with a condition
restricting attendees to staff.
Key takeaways
Model approvals and audit records as one event stream, linked by IDs, so every action can be traced to the rule, grant and person that allowed it. Extend the AU-3 baseline with agent identity, principal, grant, tool definition hash, hashed arguments, what the approver saw and what content the agent ingested, and never log secret values. Protect the trail with access control the agent cannot touch, immutable storage, and a hash chain anchored externally, and move to Merkle-tree logs only when outside parties need to audit you. Design approvals for human limits: gate on effect, render the concrete outcome, bind approval to the exact call, expire it, and measure latency and approval rates to find rules nobody is reading. Base investigations on actions and inputs, not on the model’s account of its reasoning.
How primitive approaches this. The pass privacy policy states that it keeps “approval and expiry times, and an audit receipt of each use” for connected agents; that “Audit receipts show which item was used, for which site and when, and whether the use succeeded. They never contain the password or other secret.”; and that account deletion removes “account-owned agent grants, approvals, audit events and execution receipts” [18]. These are primitive’s own statements; the schema here is a general reference for any agent stack.
Sources and further reading
- OWASP Gen AI Security Project. (2025). LLM06:2025 Excessive Agency (OWASP Top 10 for LLM Applications 2025). OWASP Foundation. https://genai.owasp.org/llmrisk/llm062025-excessive-agency/
- Model Context Protocol. (2026). Tools (Specification, revision 2026-07-28). https://modelcontextprotocol.io/specification/2026-07-28/server/tools
- Chan, A., Ezell, C., Kaufmann, M., Wei, K., Hammond, L., Bradley, H., Bluemke, E., Rajkumar, N., Krueger, D., Kolt, N., Heim, L., & Anderljung, M. (2024). Visibility into AI Agents. Proceedings of the 2024 ACM Conference on Fairness, Accountability, and Transparency (FAccT ’24). https://arxiv.org/abs/2401.13138
- Joint Task Force. (2020). Security and Privacy Controls for Information Systems and Organizations (NIST SP 800-53 Rev. 5), AU family and AC-6(9). National Institute of Standards and Technology. https://csrc.nist.gov/pubs/sp/800/53/r5/upd1/final
- Greshake, K., Abdelnabi, S., Mishra, S., Endres, C., Holz, T., & Fritz, M. (2023). Not what you’ve signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection. Proceedings of the 16th ACM Workshop on Artificial Intelligence and Security (AISec ’23), 79–90. https://doi.org/10.1145/3605764.3623985 (preprint: https://arxiv.org/abs/2302.12173)
- Invariant Labs. (2025, 1 April). MCP Security Notification: Tool Poisoning Attacks. Invariant Labs blog. https://invariantlabs.ai/blog/mcp-security-notification-tool-poisoning-attacks
- Shavit, Y., Agarwal, S., Brundage, M., Adler, S., O’Keefe, C., Campbell, R., Lee, T., Mishkin, P., Eloundou, T., Hickey, A., Slama, K., Ahmad, L., McMillan, P., Beutel, A., Passos, A., & Robinson, D. G. (2023). Practices for Governing Agentic AI Systems. OpenAI. https://cdn.openai.com/papers/practices-for-governing-agentic-ai-systems.pdf
- Australian Signals Directorate’s Australian Cyber Security Centre and co-authors. (2024). Best practices for event logging and threat detection. Australian Signals Directorate. https://www.cyber.gov.au/publication/best-practices-for-event-logging-and-threat-detection
- Model Context Protocol. (2026). Key Changes (Specification, revision 2026-07-28). https://modelcontextprotocol.io/specification/2026-07-28/changelog
- OpenTelemetry. (2026). Semantic conventions for generative AI systems, including MCP conventions (Development status). OpenTelemetry GenAI semantic conventions repository. https://github.com/open-telemetry/semantic-conventions-genai
- Schneier, B., & Kelsey, J. (1999). Secure audit logs to support computer forensics. ACM Transactions on Information and System Security, 2(2), 159–176. https://doi.org/10.1145/317087.317089 (author’s page: https://www.schneier.com/academic/archives/1999/05/secure_audit_logs_to.html)
- Crosby, S. A., & Wallach, D. S. (2009). Efficient Data Structures for Tamper-Evident Logging. Proceedings of the USENIX Security Symposium 2009. https://www.usenix.org/legacy/event/sec09/tech/full_papers/crosby.pdf
- Laurie, B., Langley, A., & Kasper, E. (2013). Certificate Transparency (RFC 6962). IETF. https://www.rfc-editor.org/rfc/rfc6962
- Akhawe, D., & Felt, A. P. (2013). Alice in Warningland: A Large-Scale Field Study of Browser Security Warning Effectiveness. Proceedings of the 22nd USENIX Security Symposium, 257–272. https://www.usenix.org/conference/usenixsecurity13/technical-sessions/presentation/akhawe
- Parasuraman, R., & Manzey, D. H. (2010). Complacency and Bias in Human Use of Automation: An Attentional Integration. Human Factors, 52(3), 381–410. https://doi.org/10.1177/0018720810376055 (open-access copy: https://doi.org/10.14279/depositonce-8052)
- Model Context Protocol. (2026). Security Best Practices (documentation for protocol revision 2026-07-28). https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/security_best_practices
- Kent, K., & Souppaya, M. (2006). Guide to Computer Security Log Management (NIST SP 800-92). National Institute of Standards and Technology. https://csrc.nist.gov/pubs/sp/800/92/final
- Primitive AI (PRIMITIVE AI LABS PTY LIMITED). (2026, 25 October). Primitive Pass Privacy Policy, sections 03 (“AI agent access”) and 08 (“Account deletion”). https://pass.primitiveai.com.au/privacy.html (primitive’s own statements; effective 25 October 2026)