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
- In plain words
- What it gives you for memory: from the current docs
- How to implement it (ServiceApps): code and output
- The 27 solutions with AutoGen: replace, complement or still yours
- Use both: what you still build
- 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:
- Short-term:
BufferedChatCompletionContext(buffer_size=N),TokenLimitedChatCompletionContext(model_client, token_limit=...)(experimental),HeadAndTailChatCompletionContext(head_size, tail_size),UnboundedChatCompletionContext. - Persistence:
await agent.save_state()/load_state(state), also for teams; the state (everything the app must remember to continue correctly) is a dict you store yourself. - Long-term: the
Memoryprotocol (add,query,update_context,clear) withListMemory,ChromaDBVectorMemory,RedisMemory,Mem0Memory. - Deleting:
memory.clear()(the whole store),model_context.clear(),team.reset(); no TTL or per-user delete in the docs.
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.
- Give the agent (an AI that chooses which tools to use to answer) a model context with a limit (
BufferedChatCompletionContext). - Attach long-term memory (
memory=[ListMemory()]or a vector (text turned into a list of numbers so similar meanings sit close together) memory). - After each turn,
save_state()and store the JSON (a simple text format for structured data) under your session key. - 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.
save_state()gives you a dict; where it's stored, under which key, and for how long is your job.memory.clear()clears everything in that store; keep one store per user if you need per-user deletion.- No redaction: mask before
memory.add().
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 solution | With AutoGen | How | Solution |
|---|---|---|---|
| Three-Tier Memory: Short-Term (Context Window) (what the AI sees in the current call) | π Replace | The agent (an AI that chooses which tools to use to answer)'s model context: BufferedChatCompletionContext, TokenLimitedChatCompletionContext, HeadAndTailChatCompletionContext | Deep dive |
| Three-Tier Memory: Long-Term (Vector Store) (knowledge saved outside the model and searched when needed) | π Replace | ChromaDBVectorMemory, RedisMemory, Mem0Memory | Deep dive |
| Three-Tier Memory: Episodic (Experience Log) (a record of what happened, step by step) | π€ Complement | ListMemory keeps a chronological list; the audit log (a permanent record of who did what and when) is yours | Deep dive |
| Agentic Outcome: Token Budgets (keeping each call within a planned size) | π Replace | TokenLimitedChatCompletionContext(token_limit=...) (experimental) | Deep dive |
| Agentic Outcome: Hybrid Memory Systems (recent chat in the window plus long-term search) | π Replace | Model 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) | π€ Complement | save_state() / load_state() return a dict; storing it is yours | Deep dive |
| Token Counting Middleware (code that counts tokens before every AI call and acts when the window gets too full) | π Replace | TokenLimitedChatCompletionContext 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) | π Replace | Tools (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) | π€ Complement | HeadAndTailChatCompletionContext can always keep the first messages β | Deep dive |
| Textual Summarization (rewriting old conversation into short, dense notes) | π Still yours | Not built in | Deep dive |
| Rolling Summaries (a short running summary that replaces old conversation turns) | π Still yours | Not built in | Deep dive |
| Entity Extraction (pulling key facts (names, dates, IDs) out of text into a structured record) | π€ Complement | Mem0Memory extracts facts (an outside service) | Deep dive |
| Vector Compression via RAG (storing text as vectors and pulling back only the parts that match) | π Replace | ChromaDB or Redis vector (text turned into a list of numbers so similar meanings sit close together) memory | Deep dive |
| The Engineering Trade-off: Fidelity vs. Capacity (the trade-off between keeping every detail and fitting more in the window) | π Still yours | Same | Deep dive |
| The Hot/Cold State Architecture (splitting memory into what is in the current call (hot) and what is saved for later (cold)) | π€ Complement | Model context is hot; Memory and saved state (everything the app must remember to continue correctly) are cold | Deep dive |
| Structured Storage (SQL/Postgres) (a database with fixed tables for exact facts) | π Still yours | None | Deep dive |
| Semantic Storage (Vector DB like Pinecone, Weaviate, or Chroma) (a vector database that finds text by meaning) | π Replace | ChromaDBVectorMemory, RedisMemory | Deep dive |
| Session Caching (Redis/Key-Value) (saving a conversation's state so it can pause and resume) | π€ Complement | save_state() gives a dict; you store it under your session key | Deep dive |
| The Rehydration Pattern (fetch saved state, keep only what's relevant, and put it back into the next call) | π€ Complement | load_state(); memory adds relevant items to the context | Deep dive |
| Sanitization layer (code that masks personal details and secrets before anything is saved) | π Still yours | No redaction | Deep dive |
| TTL (time-to-live) expiration (deleting saved data automatically after a set time) | π Still yours | Not mentioned | Deep dive |
| GDPR Right to Be Forgotten (a person's right to have their stored data deleted (from the EU's GDPR law)) | π€ Complement | memory.clear() clears a whole store, not one user | Deep dive |
| Engineering Fix: Recursive Goal Injection (repeating a short reminder of the rules before every AI answer) | π Still yours | Yours to add β | Deep dive |
| Engineering Fix: Strict RAG and Citation Enforcement (answering only from retrieved sources, and flagging any answer without one) | π Still yours | Yours β | Deep dive |
| Input Filtering: Relevance Pruning (checking and trimming a question before the AI sees it) | π Still yours | Yours β | Deep dive |
| Process Control: Self-Correction Loop (checking the AI's answer and sending it back once to fix what failed) | π€ Complement | A 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) | π Replace | Structured output on AssistantAgent β | Deep dive |
Use both: what you still build
Still yours with AutoGen:
- Textual Summarization (rewriting old conversation into short, dense notes): Not built in
- Rolling Summaries (a short running summary that replaces old conversation turns): Not built in
- The Engineering Trade-off: Fidelity vs. Capacity (the trade-off between keeping every detail and fitting more in the window): Same
- Structured Storage (SQL/Postgres) (a database with fixed tables for exact facts): None
- Sanitization layer (code that masks personal details and secrets before anything is saved): No redaction
- TTL (time-to-live) expiration (deleting saved data automatically after a set time): Not mentioned
- Engineering Fix: Recursive Goal Injection (repeating a short reminder of the rules before every AI answer): Yours to add
- Engineering Fix: Strict RAG and Citation Enforcement (answering only from retrieved sources, and flagging any answer without one): Yours
- Input Filtering: Relevance Pruning (checking and trimming a question before the AI sees it): Yours
Use both (complement), with your rules on top:
- Three-Tier Memory: Episodic (Experience Log) (a record of what happened, step by step):
ListMemorykeeps a chronological list; the audit log (a permanent record of who did what and when) is yours - Agentic Outcome: Strict State Serialization (saving state so work can pause, crash and resume without loss):
save_state()/load_state()return a dict; storing it is yours - System Prompt Pinning (keeping the rules in a protected place that is sent on every call and never trimmed):
HeadAndTailChatCompletionContextcan always keep the first messages - Entity Extraction (pulling key facts (names, dates, IDs) out of text into a structured record):
Mem0Memoryextracts facts (an outside service) - The Hot/Cold State Architecture (splitting memory into what is in the current call (hot) and what is saved for later (cold)): Model context is hot;
Memoryand saved state (everything the app must remember to continue correctly) are cold - Session Caching (Redis/Key-Value) (saving a conversation's state so it can pause and resume):
save_state()gives a dict; you store it under your session key - The Rehydration Pattern (fetch saved state, keep only what's relevant, and put it back into the next call):
load_state(); memory adds relevant items to the context - GDPR Right to Be Forgotten (a person's right to have their stored data deleted (from the EU's GDPR law)):
memory.clear()clears a whole store, not one user - Process Control: Self-Correction Loop (checking the AI's answer and sending it back once to fix what failed): A second agent (an AI that chooses which tools to use to answer) can review (reflection pattern)
In NurseOps Now
Not used in NurseOps Now. AutoGen is planned as feature F15 in restaurant-ai-platform.
Trade-offs
- Ready-made window limits (including a token (the unit the AI reads and is billed by, about three quarters of a word) limit), but persistence is a dict you manage.
- Multi-agent conversations multiply memory: each agent (an AI that chooses which tools to use to answer) has its own context.
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.
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