- Identity answers who (or what) is acting.
- Runtime security limits what the agent can reach while it runs.
- Observability provides the evidence needed to understand what actually happened.
- Before execution: identity answers who is making the request — both the agent’s workload identity and any user or service it acts for.
- During execution: runtime security enforces boundaries (isolation, network restrictions, tool policies, and human approvals).
- After (and throughout): observability records what happened so you can audit, investigate, and meet compliance requirements.

At-a-glance: the three layers
Think about these controls in lifecycle terms: identity before a run, containment during a run, and evidence both during and after the run. Use all three together — none is sufficient on its own.
Identity
A risky and common pattern is to assign many agents a shared service account with broad administrative permissions and long-lived credentials. That pattern creates two hazards:- Excessive privileges (violates least privilege).
- Logs that cannot distinguish one agent from another — or an agent from a human.
- Give each agent a distinct workload identity.
- Scope its permissions narrowly (least privilege).
- Use short-lived credentials that are issued on demand and expire quickly.
- When an agent acts on behalf of a user, use delegated access (for example, an on-behalf-of token exchange) so logs preserve both identities: which agent performed the action and on whose behalf.
- Give agents distinct workload identities.
- Use short-lived credentials.
- Grant the least privilege necessary.
Runtime security (containment)
Identity tells us who the agent is; runtime security controls the environment where the agent executes. The central idea is a sandbox: an isolated filesystem, CPU/memory limits, time limits per run, and caps on token usage or spend. By default, block high-risk resources (open internet access, production databases, raw shell access). Allow approved capabilities through explicit guardrails: API/tool allowlists, required human approvals for high-impact actions, and policy checks (for example using Open Policy Agent) on privileged operations. These runtime controls are designed with the assumption that prompt-level defenses can fail — prompt injection can still happen. A properly configured sandbox and runtime guardrails can turn a compromised instruction into a failed attempt rather than a production incident. Important: sandboxing does not replace authorization — use both together.
- Sandbox: isolated FS, ephemeral containers, no host mounts.
- Resource caps: CPU, memory, execution time, token limits, spend limits.
- Network boundaries: deny-by-default egress; allow explicit endpoints.
- Tool/API allowlists: only approved integrations.
- Human-in-the-loop: approvals for high-impact actions.
- Policy enforcement: automatic checks using a policy engine such as OPA.
Observability (evidence)
Observability gives you an auditable trace of what happened during a run. A robust trace should include:- Agent identity and any delegated user identity.
- Model calls and token usage.
- Tool calls and their responses.
- Policy decisions and human approvals.
- Timing, costs, and other run metadata.
- Real-time detection (e.g., flagging a draft that contains an external address).
- Post-run reconstruction and investigation.
- Compliance and audit evidence when you cannot exactly replay a model output.
Traces may contain sensitive data (prompts, tool requests, PII). Protect traces with redaction, encryption, strict access controls, and curated retention policies.
Quick assessment checklist for any agent
If you can’t answer these, mark them as remediation priorities.
Summary
Identity, containment, and evidence form a practical, layered foundation for securing agents:- Give each agent a distinct identity with short-lived, least-privilege credentials.
- Limit what the agent can reach at runtime with sandboxing, allowlists, policy checks, and human approvals.
- Preserve reliable observability so you can detect, investigate, and audit what the agent did.