liveBook · Manning

Working memory

As explained in Context Engineering

Short-term memory is information about the current user-agent session, including prior turns and agent actions, that ends with the session.

Working memory, also called short-term or contextual memory, records the current user-agent session: earlier turns and actions taken by the agent. It gives separate LLM calls conversational continuity, even though the model itself is stateless. section 1.5.4 section 5.1.1

The session lives outside the model in the agent harness or application. For each request, the harness sends a selected view of the history; anything omitted is invisible to the model. Context-window and token-budget limits make curation necessary as a conversation grows. A policy can trim older turns, summarize them, or combine both approaches. section 5.1.1 section 5.5.3

A travel preference

A user requests evening flights. The agent can continue applying that preference several turns later if the relevant session history is included in the context. To use the preference in a new session weeks later, the application must first save it to persistent long-term memory and retrieve it when relevant. section 1.5.4

Working memory preserves what was said and done; state tracks structured operational variables such as goals, progress, and collected parameters. Long-term memory persists useful information across sessions. Frameworks may combine or separate these abstractions, so their object names do not always match the conceptual boundaries. section 5.1.3 section 1.5.4

Table 5.1 Names given to short-term memory, long-term memory, and state in the main agent frameworks
Framework Short-term memory Long-term memory State

LangGraph

Short-term memory

Store

Graph state

LlamaIndex

Chat memory buffer

Memory blocks

Workflow context

Letta

Message buffer

Archival memory

Core memory blocks

OpenAI Agents SDK

Session

Not built in

Run context object

Google ADK

Session events

Memory service

Session state

Compare the names used for session history, persistent memory, and state across agent frameworks. section 5.1.3

Listing 5.4 Illustrative Python excerpt showing a custom session that curates short-term memory before each agent run
from agents import Agent, Runner
from agents.memory.session import SessionABC
from collections import deque
from typing import List

class SummarizingSession(SessionABC): #1
    def _materialize(self):
        trimmed = self._trim_to_last_turns(list(self._items)) #2
        if self._summary:
            summary_msg = { #3
                "type": "message",
                "role": "assistant",
                "content": f"Running summary:\n{self._summary}",
            }
            return [summary_msg] + trimmed
        return trimmed

    async def _refresh_summary_locked(self): #4
        prompt = f"Update the summary with older history:\n{drop_text}"
        result = await Runner.run(summarizer, prompt)
        self._summary = (result.final_output or "").strip()

agent = Agent(name="Support", model="gpt-5",
              instructions="Troubleshoot step-by-step.")
session = SummarizingSession("support_demo", max_turns=6) #5
result = await Runner.run(agent, user_input, session=session) #6

Inspect a schematic OpenAI Agents SDK session that keeps recent turns and prepends a running summary; the excerpt omits plumbing and is not runnable as printed. section 5.5.3

How Context Engineering covers it

How deep it goes
Explains session replay and curation, then sketches a custom session policy while leaving implementation plumbing aside.
Examples
Uses an evening-flight preference and a session that combines recent turns with a running summary.
What you can do after
Evaluate session-curation approaches, including turn trimming and summary-based compression.
How it connects
Distinguishes working memory from long-term memory and state, and relates it to the context window.

Also explained in

Compare how 11 books explain working memory →

Related concepts

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