πŸ“¦ Moved to new directory. Last updated 12.2.2026. New location: claude-config/library/03-memory-state/deep-dives/fw-autogen.html

Framework deep dive: AutoGen memory and the 27 solutions

Nov 19, 2026 · Michael Chang · Status: ⬜ not used in NurseOps Now (planned for restaurant-ai-platform, F15)

Show definitions in ( ) Β· hover a highlighted word for its meaning, click it for details Β· open with ?defs=1 to show definitions

Part of: Remembering the right things: state management in NurseOps Now Β· All 27 solutions Β· Other frameworks: LangGraph Β· CrewAI Β· LlamaIndex

Read in this order

  1. In plain words
  2. What it gives you for memory: from the current docs
  3. How to implement it (ServiceApps): code and output
  4. The 27 solutions with AutoGen: replace, complement or still yours
  5. Use both: what you still build
  6. In NurseOps Now, Trade-offs and Interview answer

In plain words

AutoGen (Microsoft) builds apps from agents (an AI that chooses which tools to use to answer) that talk to each other. Each agent (an AI that chooses which tools to use to answer) has a model context (what it sends to the model, with ready-made limits), optional memory stores it consults before answering, and save/load state (everything the app must remember to continue correctly) to pause and resume.

In plain terms: each agent (an AI that chooses which tools to use to answer) has a short notepad with a fixed number of lines, an optional reference binder, and can photocopy its notepad to continue later.

What it gives you for memory

From the official memory docs (AutoGen memory docs), checked on Nov 19, 2026:

How to implement it (ServiceApps)

Illustrative example: made-up data, no ServiceApps (a company platform for IT tickets, HR requests and help-center articles) instance. The code was run as shown; the model is a scripted stand-in, so no API key (a secret code that lets the app use a paid service) is needed.

The scenario. ServiceApps (a company platform for IT tickets, HR requests and help-center articles) Assist as one AutoGen agent (an AI that chooses which tools to use to answer) with a 4-message buffer and a small preference memory. The model is AutoGen's replay client (scripted replies), so the example runs without an API key (a secret code that lets the app use a paid service).

Steps.

  1. Give the agent (an AI that chooses which tools to use to answer) a model context with a limit (BufferedChatCompletionContext).
  2. Attach long-term memory (memory=[ListMemory()] or a vector (text turned into a list of numbers so similar meanings sit close together) memory).
  3. After each turn, save_state() and store the JSON (a simple text format for structured data) under your session key.
  4. To resume, create the agent (an AI that chooses which tools to use to answer) and load_state(); to forget, clear() the memory and delete the saved state (everything the app must remember to continue correctly).

The code (Python):

import asyncio, json
from autogen_agentchat.agents import AssistantAgent
from autogen_core.memory import ListMemory, MemoryContent, MemoryMimeType
from autogen_core.model_context import BufferedChatCompletionContext
from autogen_ext.models.replay import ReplayChatCompletionClient

async def main():
    replies = ["Which error code do you see?", "809: the VPN can't reach the server. Avoid guest Wi-Fi.", "Try your phone hotspot."]
    prefs = ListMemory()                                                          # long-term memory (7.3)
    await prefs.add(MemoryContent(content="User prefers short bullet answers", mime_type=MemoryMimeType.TEXT))
    agent = AssistantAgent("assist", model_client=ReplayChatCompletionClient(replies),
                           system_message="You are ServiceApps Assist. Cite KB numbers.",
                           model_context=BufferedChatCompletionContext(buffer_size=4),   # short-term limit (7.1)
                           memory=[prefs])
    for q in ["My VPN keeps dropping", "Error 809", "I'm on hotel Wi-Fi"]:
        r = await agent.run(task=q)
        print(f"{q!r:24} -> {r.messages[-1].content}")
    kept = await agent._model_context.get_messages()                              # what the next call would see
    print("model context keeps:", len(kept), "messages (buffer_size=4)")
    state = await agent.save_state()                                              # serialization (7.3)
    blob = json.dumps(state)
    print("saved state:", len(blob), "chars of JSON, keys:", sorted(state))
    agent2 = AssistantAgent("assist", model_client=ReplayChatCompletionClient(["(resumed)"]),
                            model_context=BufferedChatCompletionContext(buffer_size=4))
    await agent2.load_state(json.loads(blob))
    print("restored context:", len(await agent2._model_context.get_messages()), "messages")
    await prefs.clear()
    print("memory after clear():", (await prefs.query("anything")).results)

asyncio.run(main())

Output (from running the code above on Nov 19, 2026):

'My VPN keeps dropping'  -> Which error code do you see?
'Error 809'              -> 809: the VPN can't reach the server. Avoid guest Wi-Fi.
"I'm on hotel Wi-Fi"     -> Try your phone hotspot.
model context keeps: 4 messages (buffer_size=4)
saved state: 1055 chars of JSON, keys: ['llm_context', 'type', 'version']
restored context: 4 messages
memory after clear(): []

What to watch for.

The 27 solutions with AutoGen

πŸ” Replace = AutoGen does it, you configure it (9 of 27). 🀝 Complement = use both: AutoGen gives the mechanism, you add the rules (9). πŸ›  Still yours = build it yourself (9). † = not a memory feature, so from general knowledge rather than the memory docs; check the current docs.

Memory solutionWith AutoGenHowSolution
Three-Tier Memory: Short-Term (Context Window) (what the AI sees in the current call)πŸ” ReplaceThe agent (an AI that chooses which tools to use to answer)'s model context: BufferedChatCompletionContext, TokenLimitedChatCompletionContext, HeadAndTailChatCompletionContextDeep dive
Three-Tier Memory: Long-Term (Vector Store) (knowledge saved outside the model and searched when needed)πŸ” ReplaceChromaDBVectorMemory, RedisMemory, Mem0MemoryDeep dive
Three-Tier Memory: Episodic (Experience Log) (a record of what happened, step by step)🀝 ComplementListMemory keeps a chronological list; the audit log (a permanent record of who did what and when) is yoursDeep dive
Agentic Outcome: Token Budgets (keeping each call within a planned size)πŸ” ReplaceTokenLimitedChatCompletionContext(token_limit=...) (experimental)Deep dive
Agentic Outcome: Hybrid Memory Systems (recent chat in the window plus long-term search)πŸ” ReplaceModel context + memory=[...] on the agent (an AI that chooses which tools to use to answer)Deep dive
Agentic Outcome: Strict State Serialization (saving state so work can pause, crash and resume without loss)🀝 Complementsave_state() / load_state() return a dict; storing it is yoursDeep dive
Token Counting Middleware (code that counts tokens before every AI call and acts when the window gets too full)πŸ” ReplaceTokenLimitedChatCompletionContext counts with model_client.count_tokens()Deep dive
Dynamic Context Loading (giving the AI tools to fetch data only when it needs it, instead of putting everything in the prompt)πŸ” ReplaceTools (a function the AI can call, such as policy search) on AssistantAgent are standard †Deep dive
System Prompt Pinning (keeping the rules in a protected place that is sent on every call and never trimmed)🀝 ComplementHeadAndTailChatCompletionContext can always keep the first messages †Deep dive
Textual Summarization (rewriting old conversation into short, dense notes)πŸ›  Still yoursNot built inDeep dive
Rolling Summaries (a short running summary that replaces old conversation turns)πŸ›  Still yoursNot built inDeep dive
Entity Extraction (pulling key facts (names, dates, IDs) out of text into a structured record)🀝 ComplementMem0Memory extracts facts (an outside service)Deep dive
Vector Compression via RAG (storing text as vectors and pulling back only the parts that match)πŸ” ReplaceChromaDB or Redis vector (text turned into a list of numbers so similar meanings sit close together) memoryDeep dive
The Engineering Trade-off: Fidelity vs. Capacity (the trade-off between keeping every detail and fitting more in the window)πŸ›  Still yoursSameDeep dive
The Hot/Cold State Architecture (splitting memory into what is in the current call (hot) and what is saved for later (cold))🀝 ComplementModel context is hot; Memory and saved state (everything the app must remember to continue correctly) are coldDeep dive
Structured Storage (SQL/Postgres) (a database with fixed tables for exact facts)πŸ›  Still yoursNoneDeep dive
Semantic Storage (Vector DB like Pinecone, Weaviate, or Chroma) (a vector database that finds text by meaning)πŸ” ReplaceChromaDBVectorMemory, RedisMemoryDeep dive
Session Caching (Redis/Key-Value) (saving a conversation's state so it can pause and resume)🀝 Complementsave_state() gives a dict; you store it under your session keyDeep dive
The Rehydration Pattern (fetch saved state, keep only what's relevant, and put it back into the next call)🀝 Complementload_state(); memory adds relevant items to the contextDeep dive
Sanitization layer (code that masks personal details and secrets before anything is saved)πŸ›  Still yoursNo redactionDeep dive
TTL (time-to-live) expiration (deleting saved data automatically after a set time)πŸ›  Still yoursNot mentionedDeep dive
GDPR Right to Be Forgotten (a person's right to have their stored data deleted (from the EU's GDPR law))🀝 Complementmemory.clear() clears a whole store, not one userDeep dive
Engineering Fix: Recursive Goal Injection (repeating a short reminder of the rules before every AI answer)πŸ›  Still yoursYours to add †Deep dive
Engineering Fix: Strict RAG and Citation Enforcement (answering only from retrieved sources, and flagging any answer without one)πŸ›  Still yoursYours †Deep dive
Input Filtering: Relevance Pruning (checking and trimming a question before the AI sees it)πŸ›  Still yoursYours †Deep dive
Process Control: Self-Correction Loop (checking the AI's answer and sending it back once to fix what failed)🀝 ComplementA second agent (an AI that chooses which tools to use to answer) can review (reflection pattern) †Deep dive
Output Guardrails: Schema Enforcement (requiring the AI's answer to match a fixed shape, checked in code)πŸ” ReplaceStructured output on AssistantAgent †Deep dive

Use both: what you still build

Still yours with AutoGen:

Use both (complement), with your rules on top:

In NurseOps Now

Not used in NurseOps Now. AutoGen is planned as feature F15 in restaurant-ai-platform.

Trade-offs

Interview answer

"In AutoGen I'd give each agent (an AI that chooses which tools to use to answer) a bounded model context, buffered or token-limited, attach vector (text turned into a list of numbers so similar meanings sit close together) memory for long-term facts, and save_state after each turn to my own store under a session key. Clearing and retention are mine to design, because memory.clear() wipes a whole store."

All data in this post is made up.

← Back to all 27 solutions

Key terms

Every highlighted word in this post links here. Click ↩ Back to return to the spot you came from.

agent
An AI that chooses which tools to use to answer.Used in: In plain words, How to implement it (ServiceApps), The 27 solutions with AutoGen, Use both: what you still build, Trade-offs, Interview answer↩ Back to where you were
agentic outcome: hybrid memory systems
Recent chat in the window plus long-term search.Used in: The 27 solutions with AutoGen↩ Back to where you were
agentic outcome: strict state serialization
Saving state so work can pause, crash and resume without loss.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
agentic outcome: token budgets
Keeping each call within a planned size.Used in: The 27 solutions with AutoGen↩ Back to where you were
API key
A secret code that lets the app use a paid service.Used in: How to implement it (ServiceApps)↩ Back to where you were
audit log
A permanent record of who did what and when.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
dynamic context loading
Giving the AI tools to fetch data only when it needs it, instead of putting everything in the prompt.Used in: The 27 solutions with AutoGen↩ Back to where you were
engineering fix: recursive goal injection
Repeating a short reminder of the rules before every AI answer.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
engineering fix: strict rag and citation enforcement
Answering only from retrieved sources, and flagging any answer without one.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
entity extraction
Pulling key facts (names, dates, IDs) out of text into a structured record.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
gdpr right to be forgotten
A person's right to have their stored data deleted (from the EU's GDPR law).Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
input filtering: relevance pruning
Checking and trimming a question before the AI sees it.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
JSON
A simple text format for structured data.Used in: How to implement it (ServiceApps)↩ Back to where you were
output guardrails: schema enforcement
Requiring the AI's answer to match a fixed shape, checked in code.Used in: The 27 solutions with AutoGen↩ Back to where you were
process control: self-correction loop
Checking the AI's answer and sending it back once to fix what failed.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
rolling summaries
A short running summary that replaces old conversation turns.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
sanitization layer
Code that masks personal details and secrets before anything is saved.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
semantic storage (vector db like pinecone, weaviate, or chroma)
A vector database that finds text by meaning.Used in: The 27 solutions with AutoGen↩ Back to where you were
ServiceApps
A company platform for IT tickets, HR requests and help-center articles.Used in: How to implement it (ServiceApps)↩ Back to where you were
session caching (redis/key-value)
Saving a conversation's state so it can pause and resume.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
state
Everything the app must remember to continue correctly.Used in: In plain words, What it gives you for memory, How to implement it (ServiceApps), The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
structured storage (sql/postgres)
A database with fixed tables for exact facts.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
system prompt pinning
Keeping the rules in a protected place that is sent on every call and never trimmed.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
textual summarization
Rewriting old conversation into short, dense notes.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
the engineering trade-off: fidelity vs. capacity
The trade-off between keeping every detail and fitting more in the window.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
the hot/cold state architecture
Splitting memory into what is in the current call (hot) and what is saved for later (cold).Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
the rehydration pattern
Fetch saved state, keep only what's relevant, and put it back into the next call.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
three-tier memory: episodic (experience log)
A record of what happened, step by step.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
three-tier memory: long-term (vector store)
Knowledge saved outside the model and searched when needed.Used in: The 27 solutions with AutoGen↩ Back to where you were
three-tier memory: short-term (context window)
What the AI sees in the current call.Used in: The 27 solutions with AutoGen↩ Back to where you were
token
The unit the AI reads and is billed by, about three quarters of a word.Used in: Trade-offs↩ Back to where you were
token counting middleware
Code that counts tokens before every AI call and acts when the window gets too full.Used in: The 27 solutions with AutoGen↩ Back to where you were
tool
A function the AI can call, such as policy search.Used in: The 27 solutions with AutoGen↩ Back to where you were
ttl (time-to-live) expiration
Deleting saved data automatically after a set time.Used in: The 27 solutions with AutoGen, Use both: what you still build↩ Back to where you were
vector
Text turned into a list of numbers so similar meanings sit close together.Used in: How to implement it (ServiceApps), The 27 solutions with AutoGen, Interview answer↩ Back to where you were
vector compression via rag
Storing text as vectors and pulling back only the parts that match.Used in: The 27 solutions with AutoGen↩ Back to where you were