Deep dive 5 of 27: Agentic Outcome: Hybrid Memory Systems
Nov 19, 2026 · Michael Chang · Status in NurseOps Now: ✅ built
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, section Context and State Management (Intro) · All 27 solutions · ← Agentic Outcome: Token Budgets · Agentic Outcome: Strict State Serialization →
Read in this order
- In plain words: what it is, without jargon
- The problem it solves: the problem, and the standard approach in my words
- How to implement it (ServiceApps): scenario, steps, code and real output
- In NurseOps Now: built or not, and where
- Trade-offs and Interview answer
In plain words
Hybrid memory combines a short buffer of the latest messages with a search over long-term memory. The buffer keeps the flow of the conversation; the search brings back the one old fact or article that matters now.
In plain terms: remembering what someone just said, and also checking your notes from last month when they mention an old topic.
The problem it solves
LLMs are stateless (language models remember nothing between calls) and The context window: finite, expensive, volatile (the window is limited, paid per token, and gone after each call): a buffer alone forgets old facts, and long-term search alone loses the thread (one saved conversation, here one per user and case) of the conversation.
The standard approach (in my words): couple a short-term conversational buffer with long-term vector (text turned into a list of numbers so similar meanings sit close together) retrieval (finding the right section of the right policy) (RAG (retrieval-augmented generation: the AI looks things up before it answers)).
How to implement it (ServiceApps)
Illustrative example: no ServiceApps (a company platform for IT tickets, HR requests and help-center articles) instance is connected, so the scenario and data are made up. The code is a self-contained sketch; it was run on that made-up data on Nov 19, 2026, and the output below is from that run.
The setting. ServiceApps (a company platform for IT tickets, HR requests and help-center articles) Assist, an AI helper inside a company's ServiceApps (a company platform for IT tickets, HR requests and help-center articles) portal. Employees ask it IT and HR questions; it answers from knowledge-base (KB (knowledge base: a library of help articles)) articles, looks up the employee's own tickets (incidents (a ServiceApps ticket for something broken) like INC0012345) and requests, and keeps one conversation per employee and ticket.
The scenario. An employee says "it says error 809 on hotel Wi-Fi". ServiceApps (a company platform for IT tickets, HR requests and help-center articles) Assist needs both the last few turns and the right KB article (one help-center article in a knowledge base, with a number like KB0010234).
Steps.
- Keep a fixed-size (cutting text every N characters, wherever that lands) buffer of recent messages.
- Keep long-term items (KB (knowledge base: a library of help articles), saved notes) in a vector store (a database that finds text by meaning, using embeddings).
- On each question, take the buffer as-is and search long-term memory with the question.
- Send both, clearly separated, to the model.
The code (Python):
import math, re
from collections import Counter, deque
recent = deque(maxlen=4) # short-term buffer: last 2 turns
def embed(t): return Counter(re.findall(r"[a-z0-9]+", t.lower()))
def cos(a, b):
d = sum(a[w] * b[w] for w in a)
n = math.sqrt(sum(v * v for v in a.values())) * math.sqrt(sum(v * v for v in b.values()))
return d / n if n else 0.0
long_term = ["KB0010234 VPN error 809: avoid guest Wi-Fi, restart the client",
"KB0030100 Printer setup on macOS: add the printer by IP address",
"Saved note: the user often works from hotels"]
def context(question):
q = embed(question)
best = max(long_term, key=lambda d: cos(q, embed(d)))
return {"recent": list(recent), "recalled": best}
for role, text in [("user", "Hi"), ("assistant", "Hello! How can I help?"), ("user", "VPN broke again"), ("assistant", "Which error?")]:
recent.append(f"{role}: {text}")
c = context("it says error 809 on hotel wifi")
print("recent :", c["recent"])
print("recalled:", c["recalled"])
Output (from running the code above):
recent : ['user: Hi', 'assistant: Hello! How can I help?', 'user: VPN broke again', 'assistant: Which error?'] recalled: KB0010234 VPN error 809: avoid guest Wi-Fi, restart the client
What to watch for.
- Label the two parts in the prompt (the instructions and text given to the AI) ("recent conversation" vs "retrieved knowledge") so the model treats retrieved text as data.
- Retrieved text can contain instructions; never follow them (see Input Filtering (checking a question before the AI sees it, and blocking bad ones)).
- Don't recall from other users' memories; filter first.
In plain terms: a short memory for the conversation, plus a quick look in the filing cabinet for the one old note that matters.
In NurseOps Now
Built. AI Assist (the app's chat helper for staff questions) sends the last 10 turns (the buffer) and lets the model call RAG (retrieval-augmented generation: the AI looks things up before it answers) tools (a function the AI can call, such as policy search) over policies (the health plan's written rules for when tests are covered) and the user guide (search_policy, search_guide) plus case lookups. See Step 2 and Step 3.
Trade-offs
- Two memories mean two things to tune and test.
- Retrieval (finding the right section of the right policy) adds latency (how long it takes to respond); caching popular articles helps.
Interview answer
"I combine a small recent-messages buffer with retrieval (finding the right section of the right policy) over long-term memory. The buffer keeps the conversation coherent, retrieval (finding the right section of the right policy) brings back the specific article or fact the question needs, and both go into the prompt (the instructions and text given to the AI) clearly labeled."
All data in this post is made up. No real people, tickets or patient data.
← Back to all 27 solutions in the state management blog
Key terms
Every highlighted word in this post links here. Click ↩ Back to return to the spot you came from.
- AI Assist
- The app's chat helper for staff questions.Used in: In NurseOps Now↩ Back to where you were
- fixed-size
- Cutting text every N characters, wherever that lands.Used in: How to implement it (ServiceApps)↩ Back to where you were
- incident
- A ServiceApps ticket for something broken.Used in: How to implement it (ServiceApps)↩ Back to where you were
- input filtering
- Checking a question before the AI sees it, and blocking bad ones.Used in: How to implement it (ServiceApps)↩ Back to where you were
- KB
- Knowledge base: a library of help articles.Used in: How to implement it (ServiceApps)↩ Back to where you were
- KB article
- One help-center article in a knowledge base, with a number like KB0010234.Used in: How to implement it (ServiceApps)↩ Back to where you were
- latency
- How long it takes to respond.Used in: Trade-offs↩ Back to where you were
- llms are stateless
- Language models remember nothing between calls.Used in: The problem it solves↩ Back to where you were
- policies
- The health plan's written rules for when tests are covered.Used in: In NurseOps Now↩ Back to where you were
- prompt
- The instructions and text given to the AI.Used in: How to implement it (ServiceApps), Interview answer↩ Back to where you were
- RAG
- Retrieval-augmented generation: the AI looks things up before it answers.Used in: The problem it solves, In NurseOps Now↩ Back to where you were
- retrieval
- Finding the right section of the right policy.Used in: The problem it solves, Trade-offs, Interview answer↩ 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
- the context window: finite, expensive, volatile
- The window is limited, paid per token, and gone after each call.Used in: The problem it solves↩ Back to where you were
- thread
- One saved conversation, here one per user and case.Used in: The problem it solves↩ Back to where you were
- tool
- A function the AI can call, such as policy search.Used in: In NurseOps Now↩ Back to where you were
- vector
- Text turned into a list of numbers so similar meanings sit close together.Used in: The problem it solves↩ Back to where you were
- vector store
- A database that finds text by meaning, using embeddings.Used in: How to implement it (ServiceApps)↩ Back to where you were