liveBook · Manning

Working memory

As explained in Building Reliable AI Systems

An agent memory that temporarily retains information, typically for the duration of a single session.

Working memory keeps an agent’s conversation context available during a single session. If a traveler asks for flights and then adds “make sure it’s a window seat,” the agent can apply that constraint without asking for the destination and date again. Unlike persistent memory, this information is temporary and can be discarded when the session ends. section 6.2.1

Order-tracking chat

A customer supplies an order ID. The agent retains it for the session, uses it to query the order database, and can answer follow-up questions without requesting the ID again. A support agent can likewise retain a device type, operating system, and reported error while troubleshooting. section 6.2.1

A plain buffer is often enough: store messages or key details in a list or dictionary, then read them when handling the next turn. It is lightweight and needs no persistent store. Keeping the full conversation preserves recall, but long sessions can exceed a model’s context window. For those sessions, periodically summarizing the history reduces what must be carried forward; it is a trade-off when exact recall matters. section 6.2.1 section 6.2.2

class ShortTermMemory:
    def __init__(self):
        self.memory = []

    def add_message(self, message):
        self.memory.append(message)

    def get_memory(self):
        return self.memory

This minimal Python class appends messages to a list and returns the accumulated session history; it shows storage, not session lifecycle management. section 6.2.1

Start with a buffer for short conversations, where it is simpler and cheaper. Add summarization when sessions regularly exceed the context window. For production agents needing checkpointing, human approval steps, or state across sessions, consider LangGraph state management rather than relying on standalone memory classes intended for simpler applications and prototypes. section 6.2.2

How Building Reliable AI Systems covers it

How deep it goes
Explains temporary storage through scenarios and a minimal Python class, then compares full buffers with periodic summarization.
Examples
Uses flight-seat follow-ups, order tracking, device troubleshooting, and Python message-list implementations.
What it assumes
Assumes familiarity with basic Python collections for the implementation while explaining session memory through concrete conversations.
What you can do after
Build it from scratch with a session-scoped list, and choose buffering or summarization according to conversation length and recall needs.
How it connects
Connects working memory to conversation history, persistent memory, context windows, summarization, and agent state management.

Also explained in

Compare how 7 books explain working memory →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Reliable AI Systems. The section links point to the parts of the book it draws on.