Secure Agent Reference Architecture
Put enforcement outside the model, keep the paths few and be able to prove that each control works.
Separate the system into zones: interface, agent runtime, control layer, tools, data and sandbox. Route every action through a policy point that the model cannot change, give each part its own narrow identity, deny outbound traffic by default, record decisions in a separate store and keep a tested way to stop.
What you will learn: a layered architecture, what each control point decides, how failures should behave, how to scale controls to risk and how to review a design.
Prerequisites: Agent Threat Model and OWASP Agentic Risks and Agent Identity, Authorization and Secrets. The wider business view is in Enterprise Agent and Platform Reference Architectures.
The review script runs in November 2026 with Python 3.13 and only the standard library. The architecture is a generic starting point written for this site, not a certified or vendor design.
Six principles
- The model proposes; the system decides. Permissions live in code and services.
- Least privilege. Narrow tools, data, network and time.
- Untrusted by default. Documents, tool results, other agents and model output.
- Few paths. One way to act and one way out, so they can be watched.
- Fail safely. If a control cannot decide, consequential actions do not happen.
- Evidence over claims. Each control has a test and an owner.
The layers
Draw it between the agent runtime and the control layer. Everything above can be influenced by text. Everything below should behave correctly even if the layer above is fully mistaken.
What each zone may hold
| Zone | Holds | Must not hold | Typical owner |
|---|---|---|---|
| Interface | User session, display logic | Backend keys, authorization decisions alone | Application team |
| Agent runtime | Prompts, task state, permitted context | Long-lived secrets, policy it can edit | Agent team |
| Control layer | Policy, approvals, delegation, limits | Untrusted code or documents | Platform and security |
| Tool services | Narrow credentials and validation | General-purpose pass-through access | System owners |
| Sandbox | Copies of the files for one task | Credentials, other tasks' data | Platform |
| Evidence store | Decisions, outcomes, alerts | Write access for the agent | Security operations |
Zones are logical. A small system may run several in one service, as long as the model cannot influence the code and data that enforce limits. Separate processes make that easier to prove.
One request, end to end
- The user signs in; the interface attaches verified identity.
- The runtime builds context from permitted sources and marks untrusted material.
- The model proposes a tool call.
- The runtime validates its shape.
- The policy point decides allow, ask or deny from identity, parameters and context.
- If approval is needed, the task pauses on an approval bound to that action.
- A short-lived narrow token is issued; the tool service checks it and the record.
- The result returns, labeled and trimmed.
- Output is checked and rendered safely; the whole chain is recorded.
What each point enforces
| Point | Enforces | Detail |
|---|---|---|
| Interface | Authentication, size and rate limits, safe display | Excessive Agency, Exfiltration and Privilege Escalation |
| Input checks | Obvious abuse and format problems | AI Guardrails: Input and Output Controls |
| Context builder | Access filters, provenance, tenant scope | Supply Chain and Retrieval Poisoning |
| Model gateway | Approved models, data handling, budgets | Model Routing, Fallbacks and Gateways |
| Policy point | Which actions, with which values | Action Guardrails and Policy Engines |
| Approval service | Human decisions bound to actions | Human Approval, Thresholds and Secure Logging |
| Identity service | Delegated, short-lived access | Agent Identity, Authorization and Secrets |
| Sandbox and egress | Containment and destinations | Network, Tenant and Multi-Agent Isolation |
| Output checks | Format, sensitive data, grounding | PII Redaction and Data Leakage Prevention |
| Evidence store | Tamper-evident records and alerts | Agent Tracing and OpenTelemetry |
Input and output filters reduce risk but make mistakes. The policy point, identity checks and network rules are the controls to rely on for hard limits.
Around the runtime
Hooks for enforcement
Enforcement needs places to intercept: before input reaches the model, before and after each tool call, before memory is written and before output leaves. Many frameworks offer some of these, with different names and guarantees. The OWASP Agent Control Standard, an early open specification announced in 2026, aims to describe such runtime hooks and declarative controls in a vendor-neutral way. Check its current maturity before depending on it.
| Question for any hook | Why it matters |
|---|---|
| Can it block, or only observe? | Observation is not enforcement |
| Does every path pass through it? | Sub-agents, retries and background jobs often differ |
| What happens if it raises an error or times out? | It may continue by default |
| Does it see the final parameters? | A later step could change them |
| Who can disable it? | The running agent must not be able to |
Follow the data
Draw each class of data through the system and ask where copies appear: prompts, model provider, caches, memory, indexes, traces, backups and test sets.
| Data class | May reach the model? | May be stored in traces? |
|---|---|---|
| Public | Yes | Yes |
| Internal | Approved models and regions | Limited access |
| Personal or confidential | Only what the task needs | Masked or omitted |
| Secrets and payment card data | No | No |
This is an example classification. Use your organization's own and have its owners approve the answers. See Data Contracts, Access and Retention.
With several agents
- Each agent is a separate identity with its own tool list.
- Messages between them are authenticated, typed and permission-checked.
- The original user and the shrinking rights travel with the task.
- Policy applies at each action, not once at the front door.
- Budgets cover the whole task tree, and the stop switch cancels all of it.
Decide failure behavior
| Unavailable | Consequential actions | Harmless reading |
|---|---|---|
| Policy point | Refuse | Refuse unless a safe cached rule is explicitly allowed |
| Approval service | Hold and expire | Continue |
| Identity service | Refuse | Only while existing short tokens remain valid |
| Audit pipeline | Stop actions that require a record | Continue with local buffering, if accepted |
| Content filter | Hold or refuse | Defined per risk; never silently skip |
| Model provider | No new actions | Fall back only to an approved, tested model |
These are recommended defaults to discuss with owners. Write the choice down and test it by switching each dependency off.
Review a design as data
Describe the agent's tools as data and check a few rules on every change. Save as review.py and run it.
"""Review an agent design written as data. Fails the build while findings remain."""
import copy
DESIGN = {
"agent": "supplier-assistant",
"stop_switch": False,
"tools": [
{"name": "read_inbox", "untrusted_input": True, "identity": "user"},
{"name": "read_contracts", "private_data": True, "identity": "service-admin"},
{"name": "send_email", "external": True, "identity": "user", "approval": False},
{"name": "run_code", "code": True, "network": True, "identity": "agent"},
{"name": "update_vendor", "changes_state": True, "identity": "user",
"approval": False, "reversible": False},
],
}
def review(design):
tools, found = design["tools"], []
untrusted = [t["name"] for t in tools if t.get("untrusted_input")]
private = [t["name"] for t in tools if t.get("private_data")]
acting = [t["name"] for t in tools
if (t.get("external") or t.get("changes_state")) and not t.get("approval")]
if untrusted and private and acting:
found.append(f"R1 one session has untrusted input ({untrusted[0]}), private data "
f"({private[0]}) and unapproved action ({', '.join(acting)})")
for t in tools:
name = t["name"]
if t.get("identity") == "service-admin":
found.append(f"R2 {name}: shared administrator identity")
if t.get("changes_state") and not (t.get("approval") or t.get("reversible")):
found.append(f"R3 {name}: irreversible change without approval")
if t.get("code") and t.get("network", True):
found.append(f"R4 {name}: generated code can reach the network")
if not design.get("stop_switch"):
found.append("R5 no tested way to stop the agent")
return found
def improved(design):
better = copy.deepcopy(design)
better["stop_switch"] = True
by_name = {t["name"]: t for t in better["tools"]}
by_name["read_contracts"]["identity"] = "user"
by_name["send_email"]["approval"] = True
by_name["update_vendor"]["approval"] = True
by_name["run_code"]["network"] = False
return better
if __name__ == "__main__":
for label, design in (("first design", DESIGN), ("revised design", improved(DESIGN))):
findings = review(design)
print(f"{label}: {len(findings)} finding(s)")
for finding in findings:
print(" " + finding)
# A flag in a file is a claim, not proof. Each one needs a test that shows it is true.
claims = sorted({k for t in improved(DESIGN)["tools"] for k in t} - {"name"})
print("claims that still need evidence:", ", ".join(claims + ["stop_switch"]))
Output:
first design: 5 finding(s)
R1 one session has untrusted input (read_inbox), private data (read_contracts) and unapproved action (send_email, update_vendor)
R2 read_contracts: shared administrator identity
R4 run_code: generated code can reach the network
R3 update_vendor: irreversible change without approval
R5 no tested way to stop the agent
revised design: 0 finding(s)
claims that still need evidence: approval, changes_state, code, external, identity, network, private_data, reversible, untrusted_input, stop_switch
The script checks five rules against what someone wrote down. Setting a flag changes the report, not the system. For each claim, link a test that demonstrates it, for example an attempted connection from the sandbox that fails. The session rule R1 is a simplified form of Meta's Agents Rule of Two.
Evidence for each claim
| Claim | Evidence |
|---|---|
| Agent acts with user rights | Cross-user test denied by the service |
| Sandbox has no network | Connection attempts fail and are logged |
| Large actions need approval | Test call without approval is refused |
| Secrets stay out of context | Marker secret search over traces finds nothing |
| It can be stopped | Timed drill including queued tasks |
| Records are tamper-evident | An altered copy fails verification |
Scale controls to risk
| Agent type | Minimum | Add |
|---|---|---|
| Answers from public content | Input and output limits, logging, cost caps | Source controls |
| Reads private data | Delegated identity, tenant isolation, leakage controls | Egress limits, access review |
| Changes systems | Policy point, approvals, idempotency, stop switch | Reconciliation, rollback drills |
| Runs code or browses | Strong sandbox, no secrets, default-deny network | Separate environment and dedicated monitoring |
| High-impact decisions about people | Human decision, records, legal review | See Risk Tiers, Approvals and Human Oversight |
Build it in stages
- Inventory. Agents, tools, data, owners and current rights.
- Contain. Remove unused tools, deny outbound traffic, add stop switches and spending limits.
- Attribute. Separate identities and decision logs.
- Decide centrally. Policy and approvals in front of consequential tools.
- Verify continuously. Control tests, red teaming and drills.
A shared platform can supply gateway, identity, policy and logging once, so that each team does not rebuild them. See Agent Fleets and Internal Platforms. A shared component is also a shared point of failure and a valuable target, so protect and test it accordingly.
Worked design: a supplier assistant
The assistant reads supplier email, looks up contracts and drafts replies. The runtime reading email has no contract access and returns only typed fields: supplier identifier, request type and date. A second step reads the matching contract with the buyer's delegated rights and drafts a reply shown as plain text. Sending requires the buyer's approval; changing bank details is not a tool at all and follows the existing manual process. A hostile email can still produce a wrong request type, so the buyer sees the original message beside the draft.
Run a design review
- The team brings the zone diagram, tool list, data classes and the review output.
- Reviewers pick three harms that would matter most and trace each through the diagram.
- For every control on a path, ask what happens if it is wrong, absent or bypassed.
- Check the evidence for the claims rather than the description of them.
- Record findings with owners, decide what blocks release and set the next review.
Keep the review short and specific. A one-page diagram that matches the running system is worth more than a long document that does not.
Decisions to record
- Trust boundaries and which zone holds each credential
- Actions by tier, with the owner of each threshold
- Behavior when each control is unavailable
- Data kept, where and for how long
- Remaining risks, who accepted them and the review date
See Architecture Decision Records and Reviews.
Operate it
| Measure | Question it answers |
|---|---|
| Actions with a recorded policy decision | Is any path going around the control layer? |
| Denied actions by agent and rule | Is something misbehaving, or a rule wrong? |
| Rights granted but unused | Where can privilege shrink? |
| Age of unpatched components | Is maintenance keeping up? |
| Time to stop an agent in the last drill | Would containment work today? |
| Control tests passing on the live release | Do the claims still hold? |
Give exceptions an owner, a reason, a limit and an end date. An exception without an end date has quietly become the design.
Designs that look secure but are not
| Design | Problem |
|---|---|
| Rules only in the system prompt | Text can be ignored or overridden |
| A gateway with one powerful backend key | Every caller inherits it |
| A checking model with the same inputs and tools | The same content can fool both |
| Policy checks inside the agent's own writable code | The agent may change them |
| Direct tool access kept "for debugging" | A path around every control |
When the design changes
| Change | Ask again |
|---|---|
| New tool or wider scope | Which new harm is reachable, and which rule limits it? |
| New data source | Who can write to it, and who may read it? |
| New model or provider | Data terms, behavior tests and fallback |
| New users or exposure | Abuse, rate limits and support |
| Less human review | What evidence shows it is acceptable? |
Automate the triggers where you can: a change to the tool list or policy files should start the review output and the control tests, and block release if either fails.
Keep the diagram, the tool list and the review input in the same repository as the agent, so that one change request shows all three.
Common mistakes
| Mistake | Better practice |
|---|---|
| Starting from products | Start from harms, boundaries and decisions |
| Every control for every agent | Tier by risk so teams can comply |
| No owner for shared controls | Name one and fund it |
| Failure behavior left to defaults | Choose and test it |
| Review only at launch | Review on change and on schedule |
Checklist
- Every action passes a policy point the agent cannot edit
- Identities are separate and delegated access expires
- Outbound paths are listed and denied by default
- Failures are defined and tested
- Each claim has evidence and an owner
Frequently asked questions
Is this too much for a prototype?
Use test data and read-only tools in prototypes, and keep the boundary between proposing and acting from the start.
Where should the policy point run?
Outside the model and the code it can change, on every path to the tool, either as a service or enforced inside each tool service.
Does a framework provide this?
Frameworks may offer hooks and checks. Identity, network, data rights and evidence still need your platform.
How often should the architecture be reviewed?
When tools, data, models or exposure change, after incidents and at a regular interval set by risk.
References and further reading
- OWASP Top 10 for Agentic Applications 2026
- Meta: Agents Rule of Two
- NIST NCCoE project on agent identity and authorization
- OWASP Agent Control Standard
- NIST SP 800-207: Zero Trust Architecture
Next steps
AI Guardrails: Input and Output Controls
Design the content checks.
Action Guardrails and Policy Engines
Build the policy point.
Lab: Least Privilege, Authentication and RBAC
Practice the controls in code.