Why your chatbot feels slow and why async memory processing is the only way to scale.
Latency is the user experience killer. If your AI assistant takes 10 seconds to reply because it’s busy summarizing the last 50 messages to "update its memory," your product is dead on arrival.
The mistake most developers make is trying to do everything in the critical path (the "Hot Path").
User Message -> Retrieval -> Update Memory (Slow) -> Generate Response -> Send to User.
This is naive. Human brains don't work this way. When you tell me your name, I respond instantly. I don't pause for 30 seconds to file that information into my long-term storage hippocampus. That happens later (mostly while we sleep).
We need to replicate this Fast Brain / Slow Brain architecture in software.
Brain 1: The Fast Brain (The Hot Path)
This is your read-path. It must be blazing fast.
- Input: User query.
- Action: Look up existing state (e.g., "User Name: Mudia", "Role: Dev").
- Output: Immediate context injection.
This path does zero heavy lifting. It does not summarize. It does not extract new facts. It just reads.
Brain 2: The Slow Brain (The Cold Path)
This is an asynchronous background worker. It runs after the response is sent to the user.
- Trigger: Conversation turn complete.
- Action: Analyze the new text. Extract new facts ("User moved to San Francisco").
- Conflict Resolution: Compare with old facts. (e.g., Overwrite "Location: Lagos").
- Output: Update the database.
By moving the "learning" phase out of the request/response cycle, you keep your bot snappy while still retaining deep context.
The Cost Benefit
This also saves money. You don't need a GPT-4 class model for the "Fast Brain." You just need a database read. You only spend the compute credits on the "Slow Brain" when there is actually new information to process.
If you are building stateful agents, stop blocking the main thread. Decouple your reads from your writes.
We built the Fast/Slow brain architecture directly into @mzhub/cortex so you don't have to wire up your own message queues.

Top comments (0)