Blog
Agentic AI Chapter 6: Agent State, Memory and Context Management

On this page
Part of the Agentic AI study series.
The model is stateless. It does not remember past calls by itself. The runtime maintains state and hands the model the relevant context at each step. Good state and context management means better decisions, fewer tool calls, and a more reliable agent.

📊 Real-World Example: An Order Return With State
- The user asks where order #408-12345 is. The runtime stores the goal and order ID, and the agent calls
get_order_status. - The result says delivered on Oct 12. State now holds the order status.
- The user says "I want to return it". State holds the intent, so the agent knows which order "it" means and calls
get_return_policy. - The policy says returnable within 30 days, and the agent calls
create_return. - A return is created and the agent confirms the pickup date.
The user never repeated the order number. The runtime kept it.
🔴 CHECKPOINT: Remember
| Memory type | What it stores | Lifespan |
|---|---|---|
| Conversation | Recent messages, intent, important facts | Short term (session) |
| Working | Intermediate results, current plan, tool outputs | Short term (iteration) |
| Long-term | Profile, preferences, history | Across sessions |
What goes into context: system instructions, recent conversation history, relevant user context, and the current state.
Context strategies: recent window, summarization, filtering, retrieval (RAG), and selective tool results.
Persist: user profile and preferences, a summary of past orders, frequent questions. Do not persist: sensitive personal data such as full payment details, temporary tool results, unnecessary conversation details.
State is maintained by the runtime, not the model.
🛠️ From My Own Work
My project keeps a note that I handle all commits myself. That is long-term memory: it lives outside any one conversation and is read back at the start of the next. Another lesson in the same area: when I changed the active theme in a config file and nothing changed, the real value was stored in a database. State often lives somewhere other than where you first look.
← Previous: Tool Execution and Observability · Back to the series start · Next: Planning, Routing and Decisions →