匠人学院 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
Memory System Design
On this page

Designing Agent Memory

Store what the agent needs to continue accurately, not everything it has ever seen. Long context can still lose important constraints among irrelevant messages.

#Three distinct stores

Working context contains the current request, recent observations and relevant instructions. Task state tracks completed steps, unresolved blockers and artifact locations. Long-term memory keeps reusable, verified facts across sessions.

A sliding message window is simple but can discard an early constraint. A summary compresses context but can distort uncertainty. Keep critical rules and task status explicitly structured instead of relying on either method alone.

#Retrieval is selective memory

RAG can retrieve past decisions or document passages when needed. Store source, timestamp, owner, access level and version with the text. Hybrid keyword/vector retrieval can help with exact identifiers as well as semantic questions, but evaluate it against your own data.

Permissions, balances and account settings are exact operational facts. Read them from their authoritative structured records; a vaguely similar vector result is not a safe substitute.

#Memory must expire and change

Support corrections, deletion and retention policies. A previously correct fact may be stale after a policy or product change. Record verification status so a summary does not turn an old hypothesis into current truth.

Before writing a durable memory, ask whether it is necessary, authorized and useful later. Treat content proposed by a model or retrieved from the web as untrusted until checked. Never store secrets in general retrieval indexes.

#Start small

A lightweight system can use bounded recent context plus a structured task record. Add a persistent conversation store when restart recovery is required, then retrieval when cross-session knowledge reuse becomes measurable. Test two users, conflicting updates, deletion and an old memory that must no longer influence an answer.

LangChain memory · Security

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