Secure Agent Reference Architecture

Put enforcement outside the model, keep the paths few and be able to prove that each control works.

BeginnerIntermediateExpert · 13 min read · Last updated:

In short

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.

Versions used

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.

Beginner The picture

Six principles

  1. The model proposes; the system decides. Permissions live in code and services.
  2. Least privilege. Narrow tools, data, network and time.
  3. Untrusted by default. Documents, tool results, other agents and model output.
  4. Few paths. One way to act and one way out, so they can be watched.
  5. Fail safely. If a control cannot decide, consequential actions do not happen.
  6. Evidence over claims. Each control has a test and an owner.

The layers

Interfacesign-in, input limits, safe rendering
Agent runtimecontext building, model calls, step and spend limits
Control layerpolicy, approvals, token exchange, kill switch
Tool servicesnarrow operations, validation, record-level rights
Systems and datatenant isolation, encryption, backups
A sandbox for generated code and an egress proxy sit beside the runtime. Logs flow from every layer to a separate store.
The most important line

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

ZoneHoldsMust not holdTypical owner
InterfaceUser session, display logicBackend keys, authorization decisions aloneApplication team
Agent runtimePrompts, task state, permitted contextLong-lived secrets, policy it can editAgent team
Control layerPolicy, approvals, delegation, limitsUntrusted code or documentsPlatform and security
Tool servicesNarrow credentials and validationGeneral-purpose pass-through accessSystem owners
SandboxCopies of the files for one taskCredentials, other tasks' dataPlatform
Evidence storeDecisions, outcomes, alertsWrite access for the agentSecurity 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

  1. The user signs in; the interface attaches verified identity.
  2. The runtime builds context from permitted sources and marks untrusted material.
  3. The model proposes a tool call.
  4. The runtime validates its shape.
  5. The policy point decides allow, ask or deny from identity, parameters and context.
  6. If approval is needed, the task pauses on an approval bound to that action.
  7. A short-lived narrow token is issued; the tool service checks it and the record.
  8. The result returns, labeled and trimmed.
  9. Output is checked and rendered safely; the whole chain is recorded.
Intermediate Control points

What each point enforces

PointEnforcesDetail
InterfaceAuthentication, size and rate limits, safe displayExcessive Agency, Exfiltration and Privilege Escalation
Input checksObvious abuse and format problemsAI Guardrails: Input and Output Controls
Context builderAccess filters, provenance, tenant scopeSupply Chain and Retrieval Poisoning
Model gatewayApproved models, data handling, budgetsModel Routing, Fallbacks and Gateways
Policy pointWhich actions, with which valuesAction Guardrails and Policy Engines
Approval serviceHuman decisions bound to actionsHuman Approval, Thresholds and Secure Logging
Identity serviceDelegated, short-lived accessAgent Identity, Authorization and Secrets
Sandbox and egressContainment and destinationsNetwork, Tenant and Multi-Agent Isolation
Output checksFormat, sensitive data, groundingPII Redaction and Data Leakage Prevention
Evidence storeTamper-evident records and alertsAgent 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

Before releasepinned components, review, evaluation and attack tests
While runningmonitoring, limits, alerts, kill switch
After change or eventrollback, response, new tests

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 hookWhy 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 classMay reach the model?May be stored in traces?
PublicYesYes
InternalApproved models and regionsLimited access
Personal or confidentialOnly what the task needsMasked or omitted
Secrets and payment card dataNoNo

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

UnavailableConsequential actionsHarmless reading
Policy pointRefuseRefuse unless a safe cached rule is explicitly allowed
Approval serviceHold and expireContinue
Identity serviceRefuseOnly while existing short tokens remain valid
Audit pipelineStop actions that require a recordContinue with local buffering, if accepted
Content filterHold or refuseDefined per risk; never silently skip
Model providerNo new actionsFall 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.

Expert Review and scale

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
Zero findings is not secure

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

ClaimEvidence
Agent acts with user rightsCross-user test denied by the service
Sandbox has no networkConnection attempts fail and are logged
Large actions need approvalTest call without approval is refused
Secrets stay out of contextMarker secret search over traces finds nothing
It can be stoppedTimed drill including queued tasks
Records are tamper-evidentAn altered copy fails verification

Scale controls to risk

Agent typeMinimumAdd
Answers from public contentInput and output limits, logging, cost capsSource controls
Reads private dataDelegated identity, tenant isolation, leakage controlsEgress limits, access review
Changes systemsPolicy point, approvals, idempotency, stop switchReconciliation, rollback drills
Runs code or browsesStrong sandbox, no secrets, default-deny networkSeparate environment and dedicated monitoring
High-impact decisions about peopleHuman decision, records, legal reviewSee Risk Tiers, Approvals and Human Oversight

Build it in stages

  1. Inventory. Agents, tools, data, owners and current rights.
  2. Contain. Remove unused tools, deny outbound traffic, add stop switches and spending limits.
  3. Attribute. Separate identities and decision logs.
  4. Decide centrally. Policy and approvals in front of consequential tools.
  5. 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

Illustrative example

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

  1. The team brings the zone diagram, tool list, data classes and the review output.
  2. Reviewers pick three harms that would matter most and trace each through the diagram.
  3. For every control on a path, ask what happens if it is wrong, absent or bypassed.
  4. Check the evidence for the claims rather than the description of them.
  5. 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

MeasureQuestion it answers
Actions with a recorded policy decisionIs any path going around the control layer?
Denied actions by agent and ruleIs something misbehaving, or a rule wrong?
Rights granted but unusedWhere can privilege shrink?
Age of unpatched componentsIs maintenance keeping up?
Time to stop an agent in the last drillWould containment work today?
Control tests passing on the live releaseDo 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

DesignProblem
Rules only in the system promptText can be ignored or overridden
A gateway with one powerful backend keyEvery caller inherits it
A checking model with the same inputs and toolsThe same content can fool both
Policy checks inside the agent's own writable codeThe agent may change them
Direct tool access kept "for debugging"A path around every control

When the design changes

ChangeAsk again
New tool or wider scopeWhich new harm is reachable, and which rule limits it?
New data sourceWho can write to it, and who may read it?
New model or providerData terms, behavior tests and fallback
New users or exposureAbuse, rate limits and support
Less human reviewWhat 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

MistakeBetter practice
Starting from productsStart from harms, boundaries and decisions
Every control for every agentTier by risk so teams can comply
No owner for shared controlsName one and fund it
Failure behavior left to defaultsChoose and test it
Review only at launchReview 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

Next steps