Chapter 5: Memory and state in agentic systems
The introduction identifies memory and state as context sources an LLM-based system maintains across turns, distinguishing retained information from current status.
After this chapter you will be able to
- Memory Across Interactions. Explain that memory lets an AI agent retain and recall information across interactions, supporting continuity and personalization through short-term session context and long-term persistent records.
- State As Current Status. Describe state as the current dynamic status of the agent, its task, and its environment, maintained as context across turns.
- Memory and agent continuity. Explain why memory complements tools by carrying facts, preferences, and execution history beyond a single interaction.
- Parametric and non-parametric memory. Distinguish knowledge embedded in model parameters during training from information stored and updated outside the model at runtime, and explain why the latter suits evolving, user-specific information.
- Short-term session history. Describe short-term memory as the chronological history of one ongoing user–agent interaction, including earlier turns and the agent’s actions.
- Session replay and visibility. Explain why the application replays session history on each request and why the model can use only the portion sent within context and token limits.
- Persistent storage and retrieval. Explain how long-term memory persists across sessions and how an agent brings relevant entries into its context.
- Three long-term memory types. Distinguish semantic, episodic, and procedural memory by the information each holds and how it helps an agent.
- Memory and state boundaries. Distinguish short-term memory, long-term memory, and state by what each retains and when it is used.
- Memory management scope. Explain that memory management concerns information an agent has already produced: what to keep from earlier turns or sessions, how to keep it, and what to inject into the next call. Distinguish it from context management, which governs every source entering model context.
- Selection over storage capacity. Explain why deliberate selection matters most among memory operations: it shapes agent behavior directly, while storage capacity is secondary. Describe the aim of controlling expanding context without losing relevance or exhausting the token budget.
- Memory selection tradeoffs. Explain why an agent selects stored records for each model invocation rather than including all memory, and describe how production systems combine recency, similarity, and explicit keys.
- Sliding window memory. Describe how a sliding window retains recent interaction history, when it is useful, and why it cannot preserve continuity across extended workflows.
- Semantic relevance retrieval. Trace how relevance-based selection brings older memories back into context and explain why similarity scores need additional constraints.
- Explicit key memory lookup. Describe how stable facts are loaded by known keys and why a named-field memory block is useful for personalization and application logic.
- Purpose of memory compression. Explain how memory compression replaces older verbatim interaction history with concise summaries that retain useful information.
- Context drift during compression. Explain why successive summaries can drift from original facts and describe the safeguards given here.
- Memory Write Timing Trade-offs. Distinguish hot-path memory writing from background writing, including when new memories become available and how each approach affects response latency.
- Stored Memory Consolidation. Explain why stored memories need periodic consolidation and describe the operations the section gives for reconciling new observations with existing memories.
- Memory poisoning trust boundary. Explain how memory poisoning can occur when an extraction pipeline stores deceptive untrusted input as long-term memory that later agents treat as trustworthy.
- Memory isolation and write safeguards. Describe how scoped namespaces, write validation, and provenance tracking protect long-term memory from leakage and unsafe entries.
- Pre-built memory module value. Explain why an agentic system might use a pre-built memory module instead of building a memory pipeline from scratch, and describe the functions such modules provide.
- Current operational state. Explain that state records the changing operational status of a single agent or coordinated team and is maintained outside the model by the agent harness or application. Distinguish this working data from a conversational transcript using the customer support example.
- Five categories of state. Distinguish user, system, dialogue, environmental, and multi-agent state by what each tracks, giving a representative variable for each.
- Local and global state boundaries. Distinguish local state from global state by who can access each and what each typically holds. Explain that state scoping sets boundaries of visibility and ownership because not every component needs every state variable.
- Separation in workflow schemas. Describe how developers separate shared deliverables from agent-specific data, keeping transient scratchpads local and writing finalized results to shared state. Explain how that separation limits context pollution, accidental overwrites, and irrelevant prompt content.
- Shared runtime state topology. Describe how agents in one runtime use a common state object that contains both global and agent-local state.
- Isolated state and handoffs. Trace how agents in separate runtimes coordinate by passing relevant facts in a handoff payload.
- State topology trade-offs. Distinguish the benefits and costs of shared state versus isolated state with handoffs.
- Operational state representations. Describe how typed schemas, structured scratchpads, and append-only event streams represent agent state, including what each stores or records.
- Deterministic state transitions. Explain why state updates must be deterministic as an agent advances through a task.
- Three state update routes. Describe how graph reducers, application code, and model-generated patches can update state, including where each update is applied.
- Shared state and handoff payloads. Distinguish how agents propagate information through a shared state document from how they pass needed context in a handoff when they share no state.
- Task-relevant state projection. Explain that state selection, also called state projection, extracts only the fields needed for the immediate task before the prompt is assembled, rather than passing the entire global state to every model invocation.
- Workflow state checkpoints. Explain that state persistence saves snapshots of an active workflow and that a checkpointer can save graph state after each execution step, indexed by thread and checkpoint identifiers.
- Approval and debugging from checkpoints. Describe how saved checkpoints let a workflow pause for human approval and resume without repeating earlier steps, and let developers inspect, rewind, modify, and re-execute an earlier state.
- Stateless chat memory flow. Trace how the application preserves conversational context while keeping the model stateless between runs: it retrieves relevant memories, puts them in the instructions, calls the model, and writes the latest interaction back to memory.
- Selective memory use and ingestion. Explain why long-term memories are selectively brought into context and why writing new memories needs care.
- Cognee memory construction and search. Trace how the example stores raw text, uses cognify() to build structured memory, and uses search() to retrieve from it.
- Structured retrieval versus prompt pasting. Explain why the section favors searchable structure over pasting the same text into a prompt when information grows.
- Short-term memory curation policy. Explain why short-term memory contains a curated view rather than the full transcript, and describe the example policy of retaining recent user turns verbatim while summarizing older interactions.
- Session state update cycle. Trace how application code updates the session state after an exchange and supplies it to the model on the next turn.
- Shared Planner Executor State. Trace how the planner writes a plan to a JSON-backed workflow state and the executor reads and updates that same state to advance the workflow and record the next handoff. Explain why persisting it to disk lets the state survive restarts and be shared across runs.
What it builds on
- Memory (chapter 1) · Introduces memory as a context source.
- State (chapter 1) · Introduces state as a context source.
- Tools (chapter 4) · Tools let agents act and receive feedback during task execution.
- The context window (chapter 1) · Introduces the context window.
- Retrieval models and vector databases (chapter 3) · Introduces retrieval models and vector databases.
Section by section
Introduction
The introduction identifies memory and state as context sources an LLM-based system maintains across turns, distinguishing retained information from current status.
- Memory Across Interactions: Explain that memory lets an AI agent retain and recall information across interactions, supporting continuity and personalization through short-term session context and long-term persistent records.
Why it matters: This explains how an agent can use earlier information in later interactions. - State As Current Status: Describe state as the current dynamic status of the agent, its task, and its environment, maintained as context across turns.
Why it matters: State gives the system a representation of its present situation as a conversation progresses.
Key terms: memory, short-term session context, long-term persistent records, state, dynamic status
5.1 Memory
This section explains how memory gives agents continuity, distinguishes model-embedded from external memory, and maps external storage to the context window.
- Memory and agent continuity: Explain why memory complements tools by carrying facts, preferences, and execution history beyond a single interaction.
Why it matters: Memory is what lets an agent build on earlier interactions instead of starting over each time. - Parametric and non-parametric memory: Distinguish knowledge embedded in model parameters during training from information stored and updated outside the model at runtime, and explain why the latter suits evolving, user-specific information.
Why it matters: The distinction identifies which kind of memory a context engineer can design to support changing user and task information. - External memory storage tiers: Describe what persistent and ephemeral storage retain, and what loading and promotion do between the tiers.
Why it matters: The two tiers explain how an agent can use saved information now and retain useful results for later. - Memory blocks and session state: Distinguish the long-term memory, short-term memory, and state blocks shown in the context window.
Why it matters: These distinctions clarify what information in the context window comes from earlier interactions, the current conversation, or the application.
Key terms: memory, tools, continuity, parametric memory, non-parametric memory, context window, persistent storage, ephemeral storage, load, promotion
5.1.1 Short-term memory
This section defines short-term memory as a single session’s history and explains how the agent application replays, limits, and eventually discards that history.
- Short-term session history: Describe short-term memory as the chronological history of one ongoing user–agent interaction, including earlier turns and the agent’s actions.
Why it matters: It establishes what the agent’s session history contains. - Session replay and visibility: Explain why the application replays session history on each request and why the model can use only the portion sent within context and token limits.
Why it matters: A session can retain history that the model cannot see on a particular request. - Session lifetime and persistence: Describe the session object’s role and explain why information needed after the conversation must be saved to persistent storage.
Why it matters: It marks the boundary between a conversation’s temporary history and information retained beyond it.
Key terms: short-term memory, working memory, contextual memory, session, agent harness, stateless, context window, token budget, session object, thread
5.1.2 Long-term memory
Explains how long-term memory gives agents continuity across sessions, what its three types store, and how entries change over time.
- Persistent storage and retrieval: Explain how long-term memory persists across sessions and how an agent brings relevant entries into its context.
Why it matters: This explains how an agent can use past information without keeping every past session in its current context. - Three long-term memory types: Distinguish semantic, episodic, and procedural memory by the information each holds and how it helps an agent.
Why it matters: The distinction clarifies whether an agent is recalling a fact, a past event, or a reusable routine. - Long-term memory entry lifecycle: Describe when long-term memory entries are created, revised, consolidated, or deleted.
Why it matters: Persistent information must be kept current and removable, not merely accumulated.
Key terms: long-term memory, persistent memory, context window, explicit retrieval, semantic memory, episodic memory, procedural memory, active lifecycle, superseded, consolidated
5.1.3 Memory vs state
This section distinguishes short-term memory, long-term memory, and state by their roles, then shows how agent frameworks represent those concepts differently.
- Memory and state boundaries: Distinguish short-term memory, long-term memory, and state by what each retains and when it is used.
Why it matters: These distinctions give you a clear basis for deciding whether information belongs in interaction history, persistent memory, or operational state. - Framework representation differences: Explain why framework objects do not always map one-to-one onto the book's memory and state categories, using examples from the section.
Why it matters: A framework's object names and boundaries may differ from the conceptual distinctions used to reason about an agent.
Key terms: short-term memory, long-term memory, state, operational variables, thread state, session events, searchable memory service, dynamic session state
5.2 Memory management
Defines memory management as the part of context management that controls what an agent retains and reuses, emphasizing selection over storage capacity.
- Memory management scope: Explain that memory management concerns information an agent has already produced: what to keep from earlier turns or sessions, how to keep it, and what to inject into the next call. Distinguish it from context management, which governs every source entering model context.
Why it matters: This boundary clarifies which context decisions count as memory management. - Selection over storage capacity: Explain why deliberate selection matters most among memory operations: it shapes agent behavior directly, while storage capacity is secondary. Describe the aim of controlling expanding context without losing relevance or exhausting the token budget.
Why it matters: Keeping more information is not the same as giving the agent useful context.
Key terms: memory management, context management, earlier turns, earlier sessions, selection, storage capacity, token budget, expanding contexts
5.2.1 Memory selection
This section explains how an agent selects stored memories for the context window using recency, semantic relevance, and explicit keys.
- Memory selection tradeoffs: Explain why an agent selects stored records for each model invocation rather than including all memory, and describe how production systems combine recency, similarity, and explicit keys.
Why it matters: Selection keeps the context useful without filling it with every stored record. - Sliding window memory: Describe how a sliding window retains recent interaction history, when it is useful, and why it cannot preserve continuity across extended workflows.
Why it matters: A recent-history window is easy to manage, but important older constraints can disappear from the agent’s context. - Semantic relevance retrieval: Trace how relevance-based selection brings older memories back into context and explain why similarity scores need additional constraints.
Why it matters: Relevance retrieval can recover useful older facts without relying on a rolling conversation window alone. - Explicit key memory lookup: Describe how stable facts are loaded by known keys and why a named-field memory block is useful for personalization and application logic.
Why it matters: Keyed lookup makes essential user facts consistently available to both the model and the application.
Key terms: memory selection, context window, recency, similarity, explicit key, sliding window, short-term memory, conversational turns, tool calls, observations
5.2.2 Memory compression
This section explains how agents condense interaction history, the summary patterns they use, the risk of drift, and compaction in coding agents.
- Purpose of memory compression: Explain how memory compression replaces older verbatim interaction history with concise summaries that retain useful information.
Why it matters: Compression keeps useful history available without carrying the full transcript forward. - Three summary patterns: Distinguish rolling, hierarchical, and hybrid summaries by how they update or represent compressed history.
Why it matters: These patterns show different ways to keep compressed history useful. - Context drift during compression: Explain why successive summaries can drift from original facts and describe the safeguards given here.
Why it matters: A shorter memory is useful only if repeated compression does not gradually change the facts. - Coding agent compaction: Describe when coding agents compact a conversation and what their summaries preserve or discard.
Why it matters: Compaction is a concrete example of making room in a coding agent’s context while retaining its task direction.
Key terms: memory compression, summarization, verbatim transcripts, distilled summaries, rolling summaries, hierarchical summaries, hybrid summaries, key-value attributes, context drift, editable artifacts
5.2.3 Memory writing
This section compares when agents write extracted information to memory and explains why stored memories need periodic consolidation.
- Memory Write Timing Trade-offs: Distinguish hot-path memory writing from background writing, including when new memories become available and how each approach affects response latency.
Why it matters: The timing of a memory write affects both the user’s wait and when the agent can use the new information. - Stored Memory Consolidation: Explain why stored memories need periodic consolidation and describe the operations the section gives for reconciling new observations with existing memories.
Why it matters: Saving facts is not enough if old and conflicting entries make later retrieval less accurate.
Key terms: memory writing, hot path, background, response latency, consolidation, entity-resolution models, confidence scores, superseded facts, retrieval accuracy
5.2.4 Failure modes and safeguards
This section explains how long-term memory can fail when untrusted or outdated information is retained, and the governance safeguards that reduce those risks.
- Memory poisoning trust boundary: Explain how memory poisoning can occur when an extraction pipeline stores deceptive untrusted input as long-term memory that later agents treat as trustworthy.
Why it matters: An agent may act on a malicious statement long after the original input has passed. - Memory isolation and write safeguards: Describe how scoped namespaces, write validation, and provenance tracking protect long-term memory from leakage and unsafe entries.
Why it matters: These controls help prevent one tenant’s data or an unverified claim from becoming another agent’s trusted memory. - Memory verification and correction: Describe how verification, deletion, and audit capabilities address contradictory or stale memories and support corrections and compliance.
Why it matters: A memory store needs ways to correct or remove information after it has been saved.
Key terms: memory poisoning, untrusted input, long-term storage, provenance verification, scoped namespaces, database partition keys, write filters, extraction guardrails, provenance tracking, verification mechanisms
5.2.5 Memory management tools
This subsection explains why pre-built memory modules can simplify agent development and briefly distinguishes memory from workflow state.
- Pre-built memory module value: Explain why an agentic system might use a pre-built memory module instead of building a memory pipeline from scratch, and describe the functions such modules provide.
Why it matters: This helps you decide when an existing module can save memory-pipeline engineering work. - Historical memory and workflow state: Distinguish the historical data managed by memory from the active variables governed by state in the current workflow.
Why it matters: The distinction keeps past interactions separate from what is currently active in a workflow.
Key terms: memory pipelines, pre-built memory modules, storage, retrieval, summarization, memory, state, historical data, active variables
5.3 State
Defines state as externally maintained working data about an agentic system’s current operational status and introduces the state object that organizes it.
- Current operational state: Explain that state records the changing operational status of a single agent or coordinated team and is maintained outside the model by the agent harness or application. Distinguish this working data from a conversational transcript using the customer support example.
Why it matters: This distinction helps separate the conversation history from the changing data an application uses to run a workflow. - Structured state object: Describe the state object as the application’s structured representation of its working data and state its role as a meeting point between the context orchestrator and context manager.
Why it matters: The state object gives the application a structured place for the working data those context components meet around.
Key terms: state, short-term memory, agent harness, state object, context orchestrator, context manager
5.3.1 Categories of state
This section classifies the variables in an agent’s state object and explains why the categories help developers design state schemas.
- Five categories of state: Distinguish user, system, dialogue, environmental, and multi-agent state by what each tracks, giving a representative variable for each.
Why it matters: The categories make it easier to tell what a state variable represents before deciding how to handle it. - Purpose of state categories: Explain why organizing state variables into these categories helps developers design and maintain state.
Why it matters: An explicit schema makes changes to an agent’s state easier to anticipate and inspect.
Key terms: user state, system state, dialogue state, environmental state, multi-agent state, explicit schemas, state updates, predictable, auditable
5.3.2 State scoping
This section explains how to divide workflow state into private local state and shared global state so collaborating agents see and update only what they need.
- Local and global state boundaries: Distinguish local state from global state by who can access each and what each typically holds. Explain that state scoping sets boundaries of visibility and ownership because not every component needs every state variable.
Why it matters: The distinction determines which information an agent should keep private and which collaborators need to see. - Separation in workflow schemas: Describe how developers separate shared deliverables from agent-specific data, keeping transient scratchpads local and writing finalized results to shared state. Explain how that separation limits context pollution, accidental overwrites, and irrelevant prompt content.
Why it matters: Keeping intermediate work private makes shared state safer and gives each agent a more relevant prompt. - Shared state blackboard pattern: Explain the blackboard analogy for coordination through global state: agents inspect a shared workspace, perform specialized work, and post findings that other agents can use.
Why it matters: The blackboard analogy makes clear how a shared state can connect agents without exposing their private scratchpads.
Key terms: state scoping, local state, global state, shared state, schemas, shared workflow deliverables, agent-specific data, transient scratchpad, prompt assembly, blackboard architecture
5.3.3 Multi-agent state architectures
Explains two ways to arrange state across multiple agents and the trade-offs between them.
- Shared runtime state topology: Describe how agents in one runtime use a common state object that contains both global and agent-local state.
Why it matters: A shared state contract determines how agents see and update information when they run together. - Isolated state and handoffs: Trace how agents in separate runtimes coordinate by passing relevant facts in a handoff payload.
Why it matters: A handoff is how separately hosted agents carry needed state across their runtime boundary. - State topology trade-offs: Distinguish the benefits and costs of shared state versus isolated state with handoffs.
Why it matters: The topology choice exchanges easy access to current shared state for greater independence between agents.
Key terms: agent runtime, shared state object, global state, local state, common state contract, isolated state object, handoff payload, visibility, consistency, tight coupling
5.4 State management
Introduces five state-management operations that the following subsections will explain.
5.4.1 State representation
This section explains three ways agent systems represent operational state in code: typed schemas, structured scratchpads, and append-only event streams.
- Operational state representations: Describe how typed schemas, structured scratchpads, and append-only event streams represent agent state, including what each stores or records.
Why it matters: The representation determines how an agent’s working information is structured and made available to its code.
Key terms: state representation, typed schemas, structured scratchpads, append-only event streams
5.4.2 State update
This section explains why agent state updates must be deterministic and describes three ways to apply them.
- Deterministic state transitions: Explain why state updates must be deterministic as an agent advances through a task.
Why it matters: Predictable updates help keep an agent’s task state valid. - Three state update routes: Describe how graph reducers, application code, and model-generated patches can update state, including where each update is applied.
Why it matters: These routes distinguish who proposes a state change from the code that applies it.
Key terms: state update, deterministic, race conditions, invalid state transitions, reducers, channel handlers, application-level post-processing, model-generated state patches, harness
5.4.3 State propagation
This section explains two ways information moves between agents: through shared state or through a handoff payload.
- Shared state and handoff payloads: Distinguish how agents propagate information through a shared state document from how they pass needed context in a handoff when they share no state.
Why it matters: The way agents share information determines what the next agent can act on.
Key terms: state propagation, shared state document, context payloads, agent handoffs
5.4.4 State selection and projection
This section explains how to select task-relevant state for a prompt and tailor that selection to an agent’s role.
- Task-relevant state projection: Explain that state selection, also called state projection, extracts only the fields needed for the immediate task before the prompt is assembled, rather than passing the entire global state to every model invocation.
Why it matters: The model can focus on the state it needs without spending context on unrelated details. - Prompt and role-specific views: Describe how the harness can put selected state variables into labeled system-message lines while excluding raw payloads and intermediate calculations, and how different agents receive views suited to their roles.
Why it matters: A planner, executor, and reviewer need different parts of the same global state.
Key terms: state selection, state projection, global state, prompt projection, role-scoped views, planner, executor, reviewer
5.4.5 State persistence and checkpointing
This section explains how workflow state is checkpointed and how saved state supports recovery, human approval, debugging, and coordination.
- Workflow state checkpoints: Explain that state persistence saves snapshots of an active workflow and that a checkpointer can save graph state after each execution step, indexed by thread and checkpoint identifiers.
Why it matters: Saved checkpoints make an ongoing workflow recoverable and its earlier states available for inspection. - Approval and debugging from checkpoints: Describe how saved checkpoints let a workflow pause for human approval and resume without repeating earlier steps, and let developers inspect, rewind, modify, and re-execute an earlier state.
Why it matters: A saved state makes it possible to intervene in or investigate a workflow without starting it over. - Shared state as coordination contract: Explain how state management supports tracking execution, recovery, and synchronization, and describe the state object as a contract between agents with different responsibilities.
Why it matters: Coordinated state gives collaborating agents a common basis for continuing and tracking a task.
Key terms: state persistence, checkpointing, checkpointer, graph state, thread identifier, checkpoint identifier, human-in-the-loop execution, agent harness, time-travel debugging, persistent checkpoints
5.5 Hands-on
5.5.1 Long-term memory with Mem0 and Qdrant
This section illustrates how a stateless chat application uses Mem0 and Qdrant to retrieve and persist long-term conversational memory.
- Stateless chat memory flow: Trace how the application preserves conversational context while keeping the model stateless between runs: it retrieves relevant memories, puts them in the instructions, calls the model, and writes the latest interaction back to memory.
Why it matters: It shows how an application can carry useful context across sessions without relying on the model to remember it. - Selective memory use and ingestion: Explain why long-term memories are selectively brought into context and why writing new memories needs care.
Why it matters: More stored or retrieved memory is not automatically better; both using and ingesting it have costs.
Key terms: stateless, memory layer, Mem0, Qdrant, instructions, long-term memory, retrieval, memory ingestion, tokens
5.5.2 Graph-based long-term memory with Cognee
This section uses a minimal Cognee exercise to show how raw text becomes graph-based long-term memory that can be searched alongside a vector index.
- Cognee memory construction and search: Trace how the example stores raw text, uses cognify() to build structured memory, and uses search() to retrieve from it.
Why it matters: It shows how the example turns text into memory an agent can search in more than one way. - Structured retrieval versus prompt pasting: Explain why the section favors searchable structure over pasting the same text into a prompt when information grows.
Why it matters: It identifies the scaling benefit of making information retrievable rather than repeatedly supplying it all as prompt text. - Cognee and Mem0 memory focus: Distinguish the long-term memory illustrated by Cognee from the conversational memory illustrated by Mem0.
Why it matters: The comparison shows that long-term memory need not be a store of conversation turns.
Key terms: cognify(), search(), chunks, embeds, entities, relations, structured memory representation, corpus, prompt, fragment matching the query
5.5.3 Short-term memory curation with the OpenAI Agents SDK
This section uses a schematic OpenAI Agents SDK session to show how a short-term memory policy curates interaction history for each agent run.
- Short-term memory curation policy: Explain why short-term memory contains a curated view rather than the full transcript, and describe the example policy of retaining recent user turns verbatim while summarizing older interactions.
Why it matters: The agent can retain useful continuity without carrying forward the entire conversation. - Session-based context delivery: Describe how the Session abstraction applies the memory policy so that each Runner.run() call receives curated prior context.
Why it matters: Putting the policy in the session makes curated context available on each run without manually assembling it for every call.
Key terms: short-term memory, curation, last N user turns, running summary, Session, Runner.run(), interaction history, curated context
5.5.4 Session state with a structured scratchpad
Shows how application code maintains a structured, session-local state snapshot and passes it to a single agent on each turn.
- Session state update cycle: Trace how application code updates the session state after an exchange and supplies it to the model on the next turn.
Why it matters: The snapshot reaches the model because the application maintains and includes it, not because the model manages the state object itself. - Structured local state snapshot: Describe what the session snapshot represents, how it can be inspected, and how long it lasts.
Why it matters: Its contents and lifetime make clear that this is a snapshot of one interaction, not persistent memory.
Key terms: build_system_prompt(), update_state(), system message, session state, local state, dataclass, /state
5.5.5 Shared workflow state between planner and executor
This section illustrates how a planner and executor coordinate through shared, persistent workflow state.
- Shared Planner Executor State: Trace how the planner writes a plan to a JSON-backed workflow state and the executor reads and updates that same state to advance the workflow and record the next handoff. Explain why persisting it to disk lets the state survive restarts and be shared across runs.
Why it matters: A shared, persistent state lets separate agents continue the same workflow, even across runs.
Key terms: global state, planner agent, executor agent, JSON-backed workflow state, handoff
5.6 Summary
Where this is used later
- Governance (chapter 9) · Introduces memory as an agent context source.
- Memory for coding agents (chapter 11) · the concept of memory in an agent
- Principles (chapter 7) · The distinction between memory and state helps frame why written information does not all have the same lifetime.
- Understanding the framework landscape (chapter 10) · The framework landscape can be compared without assuming every framework uses the same memory and state boundaries.
- Context management (chapter 7) · Distinguishes the broader context-management discipline from its memory-specific branch.
- Memory architectures (chapter 12) · The earlier treatment of memory management.
- Context selection (chapter 7) · Generalizes the choice of what information enters context.
- Stale memory (chapter 12) · The use of compression to manage memory.
Concepts explained in this chapter
- memoryInformation retained across interactions or steps so an AI system can use it later.
- stateInformation representing a system's current situation or progress.
- working memoryShort-term memory is information about the current user-agent session, including prior turns and agent actions, that ends with the session.
- episodic memoryEpisodic memory is retained information about past experiences and specific historical interactions.
- memory management modelThe process of allocating, retaining, replacing, and releasing information in a system's working memory.
- external memoryNon-parametric memory is information outside a model that can be saved, retrieved, and updated at runtime.
- procedural memoryProcedural memory is retained information encoding reusable routines, workflows, and patterns for carrying out actions.
- semantic memorySemantic memory is durable factual, conceptual, and stable knowledge that remains consistent across contexts.
- summarizationThe production of a shorter representation of information while retaining selected content.
- sessionAn ongoing interaction between a user and an assistant.
- schemaA schema is a formal specification of the permitted structure, fields, and constraints of data or outputs.
- parametric knowledgeParametric memory is knowledge embedded in a model’s parameters through training.
- retention policyA retention policy specifies rules for how long records are kept and when they are deleted.
- compactionA process that summarizes an agent conversation and discards lengthy details while preserving high-level task information.
- working contextModel context is the information available to a model during inference that influences its output.
- human-in-the-loopHuman oversight is the involvement of people in monitoring, reviewing, or controlling consequential AI decisions and actions.
- continuityContinuity is the preservation of relevant state and information across interaction turns, sessions, or workflow steps.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
