匠人学院 JR Academy
Skip to article
Engineering handbook
AI Agent Engineering Handbook

Start with tool calls. Understand how an agent acts, reads observations and stops when something fails. Verify each boundary with complete code and offline tests.

5 chapters·16 guides·Open access
Security and Guardrails
On this page

Security Boundaries for Agents

Treat model output, retrieved documents and tool results as untrusted input. The application must enforce what data may be read and what actions may be executed.

#Prompt injection

A webpage may contain “ignore previous instructions” or ask the agent to reveal secrets. Delimiters and instruction hierarchy help the model interpret content, but cannot guarantee resistance. Keep external text in a data role and validate every proposed action independently.

Test malicious instructions inside documents, search snippets and tool descriptions. A successful answer to a harmless prompt does not demonstrate injection resistance.

#Least-privilege tools

Use narrow, typed operations rather than unrestricted shell commands or SQL. Check caller identity, tenant, object ownership and operation permission on the server. Constrain filesystem paths and network destinations. Validate tool arguments even when generated from a schema.

For writes, show the concrete intended action where approval is required, use idempotency and verify the external result. A tool must not return “sent” when it only prepared a draft.

#Prevent data leakage

Apply access filters at retrieval time, before private passages enter model context. A final-answer instruction to hide confidential content is too late. Keep secrets out of prompts, vector indexes, analytics and trace logs.

Enforce retention and deletion across source files, indexes, caches and stored conversations. Recheck permissions when resuming an old task because access may have changed.

#Supply chain and recovery

Review tool servers and package updates. Pin dependencies and isolate untrusted code execution. Treat saved memory as another possible injection channel; a model-proposed memory should not become a higher-priority policy.

Verify failure behavior with fixtures: unknown tool, invalid arguments, cross-tenant record, expired approval and duplicate write. Stop safely and preserve an audit trail when a boundary fails. No single guardrail or classifier establishes a secure agent system.

System Design

Core system design concepts and practical case studies

Learn the trade-offs and patterns that matter in technical interviews.

Open System Design →

FAQ

Which language should I use?
Python and TypeScript both work. Start with the language you can debug; the first exercise uses Python 3.10+ and its standard library.
Does MCP require a specific model?
No. MCP connects applications to tools and context services. Compatibility depends on the host client, transport, protocol version and authorisation; model tool-calling support is a separate check.
Does learning agents guarantee employment?
No. Use a small project to demonstrate requirements analysis, permissions, testing and maintenance. Employment outcomes depend on the role market and your actual skills.

Done reading? Next steps