Agent Security Best Practices
Ten practices for sandboxing, credential scoping, and containment - expanded into a checklist you can use in design reviews and PR gates.
Search across all documentation pages
Ten practices for sandboxing, credential scoping, and containment - expanded into a checklist you can use in design reviews and PR gates.
Agents fail closed when tools, secrets, and networks are designed as small systems that stay small under attack.
refund_order beats raw SQL, shell, or open HTTP with admin credentials.The section promise is ten core practices (items 1-10). Items 11-15 extend them into operations so the list stays useful after launch.
Remove generic shell and open HTTP tools; replace with narrow allowlisted tools. That single change collapses most blast radius.
They are framework-agnostic. LangGraph, CrewAI, Microsoft Agent Framework, OpenAI Agents SDK, and custom hosts all need the same boundaries.
Yes when they hold prod credentials or can change prod systems. Network location is not a control.
No. Use structural separation, output validation, and least-privilege tools so injection cannot unlock powerful actions.
If you cannot state the business invariant in one sentence (for example "refunds at most $X on orders for this tenant"), split or cap the tool.
At least twice when risk is high: in the tool client and at the network/proxy layer so bypasses are harder.
Prefer prebaked images. Runtime installs need network and supply-chain controls; they conflict with default-deny egress.
Long-lived admin keys in the agent env, secrets in prompts/traces, or code-exec jobs that can read os.environ full of production credentials.
Yes. Ship allowlists, budgets, and no-shell first; then containers; then minted tokens and mesh egress. Do not open autonomy faster than isolation.
You cannot revoke, alert, or forensically explain what you never logged. Practice 12 is the bridge to the observability section.
In the section sidebar as the close-out checklist, in ADRs for agent platforms, and in on-call runbooks for tool incidents.
Stack versions: Pins from the category manifest (verify at build): OpenRouter (~315+ models, July 2026 pricing/fees); LangGraph 1.0+; CrewAI 1.14+; Microsoft Agent Framework 1.0; Vercel AI SDK 6; Pydantic AI (latest); LlamaIndex (latest); OpenAI Agents SDK (latest + MCP); MCP (Linux Foundation governance); A2A (HTTP+SSE+JSON-RPC 2.0); Solana
@solana/web3.js+@solana/spl-token.
Reviewed by Chris St. John·Last updated Jul 16, 2026