robotsix_chat.memory
Persistent agent memory for robotsix-chat.
The chat agent is otherwise stateless (one independent query per message). This package adds long-term memory the agent recalls from before each reply, so knowledge accumulates across conversations.
The backend is the robotsix-memory component (a fleet service wrapping a
Hindsight memory engine) — see
:class:~robotsix_chat.memory.component.ComponentMemory. Recall is a cheap
HTTP lookup rendered at the end of the agent prompt; writes belong to the
evergoing summary pipeline (:mod:robotsix_chat.memory.push) and the
agent's explicit skill calls. When the component is disabled a
:class:NullMemory no-op is used and the agent behaves statelessly.
The public surface is the :class:ChatMemory protocol — setup /
recall / remember — so the agent depends on the interface, never on
the engine. (The previous in-process cognee backend was removed 2026-09-04
after repeated storage-engine failures; see the robotsix-memory component.)
ChatMemory
Bases: Protocol
Interface the chat agent uses to recall and persist memory.
Implementations must be safe by construction: recall and remember
must never raise into the chat request path — a memory backend that is
misconfigured or unreachable degrades to "no memory", never a failed reply.
Source code in src/robotsix_chat/memory/base.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
recall(query, *, session_id=None)
async
Return memory relevant to query as a context string ("" if none).
session_id scopes the recall to one conversation so that session-level guidance (goals, rules, preferences) is isolated across concurrent windows.
Source code in src/robotsix_chat/memory/base.py
33 34 35 36 37 38 39 40 | |
remember(user_message, assistant_message, *, session_id=None)
async
Persist a completed exchange into long-term memory.
session_id scopes the write to one conversation so that session-level guidance stays per-window.
Source code in src/robotsix_chat/memory/base.py
42 43 44 45 46 47 48 49 50 51 52 53 54 | |
set_notify_callback(callback)
Register (or clear) the user-facing escalation callback.
A backend that detects a fault auto-recovery cannot safely heal uses this to escalate to the user. Backends with no escalation path may ignore it.
Source code in src/robotsix_chat/memory/base.py
72 73 74 75 76 77 78 79 | |
set_recovery_callback(callback)
Register (or clear) the out-of-band recovery callback.
A backend that can detect a persistent freeze uses this to trigger a self-restart. Backends with no recovery path may ignore it.
Source code in src/robotsix_chat/memory/base.py
64 65 66 67 68 69 70 | |
setup()
async
Initialise the backend once (idempotent). Safe to call repeatedly.
Source code in src/robotsix_chat/memory/base.py
29 30 31 | |
status()
Return a small health snapshot ({"degraded": bool, ...}).
Read by GET /health so a frozen store is externally visible.
Must never raise.
Source code in src/robotsix_chat/memory/base.py
56 57 58 59 60 61 62 | |
NullMemory
A :class:ChatMemory that stores nothing and recalls nothing.
Used when memory is disabled or the backend is unavailable, so the agent keeps working with zero memory behaviour and no extra dependencies.
Source code in src/robotsix_chat/memory/base.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
recall(query, *, session_id=None)
async
Return an empty string (no memory stored).
Source code in src/robotsix_chat/memory/base.py
93 94 95 | |
remember(user_message, assistant_message, *, session_id=None)
async
Discard the exchange (no memory backend).
Source code in src/robotsix_chat/memory/base.py
97 98 99 100 101 102 103 104 105 | |
set_notify_callback(callback)
No-op: a null backend has nothing to escalate.
Source code in src/robotsix_chat/memory/base.py
115 116 117 | |
set_recovery_callback(callback)
No-op: a null backend has nothing to recover.
Source code in src/robotsix_chat/memory/base.py
111 112 113 | |
setup()
async
No-op: nothing to initialise.
Source code in src/robotsix_chat/memory/base.py
89 90 91 | |
status()
Report a non-degraded no-op backend.
Source code in src/robotsix_chat/memory/base.py
107 108 109 | |
ReadOnlyMemory
Wraps a :class:ChatMemory so it can recall but never write.
Recall and cognify have wildly different costs. Recall is a retrieval-only
vector lookup (~0.4 s warm, no LLM call); remember historically ran an
multi-minute LLM extraction pipeline and contends with every concurrent
recall for the same stores.
Background agents — subsessions and periodic session turns — run unattended around the clock, so letting them cognify every turn is what produced the ~$22/day bill and the write contention that slows interactive chat. But there is no reason to deny them reading what the main conversation has already learned.
This wrapper is that middle setting: full recall (including the deep
search_memory tool, which is forwarded), writes silently dropped.
Source code in src/robotsix_chat/memory/base.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
__getattr__(name)
Forward unknown attributes (notably recall_deep) to the backend.
Dynamic rather than an explicit recall_deep method so the
attribute is absent when the wrapped backend lacks it — that is
exactly what build_memory_tools probes to decide whether to offer
the search_memory tool. An explicit method would always be
present and would advertise a tool that then raises.
Only reached for names not defined on this class, so the write-side overrides above can never be bypassed.
Source code in src/robotsix_chat/memory/base.py
150 151 152 153 154 155 156 157 158 159 160 161 162 | |
__init__(inner)
Wrap inner, exposing its reads and discarding its writes.
Source code in src/robotsix_chat/memory/base.py
138 139 140 | |
recall(query, *, session_id=None)
async
Delegate to the wrapped backend — reads are the whole point.
Source code in src/robotsix_chat/memory/base.py
146 147 148 | |
remember(user_message, assistant_message, *, session_id=None)
async
Discard the exchange — background agents must not cognify.
Source code in src/robotsix_chat/memory/base.py
164 165 166 167 168 169 170 171 172 | |
set_notify_callback(callback)
No-op: escalation is driven by the writing (main-chat) agent.
Source code in src/robotsix_chat/memory/base.py
184 185 186 | |
set_recovery_callback(callback)
No-op: recovery is driven by the writing (main-chat) agent.
Source code in src/robotsix_chat/memory/base.py
180 181 182 | |
setup()
async
Initialise the wrapped backend.
Source code in src/robotsix_chat/memory/base.py
142 143 144 | |
status()
Report the wrapped backend's health, flagged read-only.
Source code in src/robotsix_chat/memory/base.py
174 175 176 177 178 | |
build_memory(memory_component=None)
Return the :class:ChatMemory for the given component settings.
Returns a :class:~robotsix_chat.memory.component.ComponentMemory when
the robotsix-memory component is enabled, a :class:NullMemory no-op
otherwise. Calls with equal configuration return the same backend
instance — see _MEMORY_CACHE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory_component
|
MemoryComponentSettings | Any
|
:class: |
None
|
Source code in src/robotsix_chat/memory/__init__.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
reset_build_memory_cache()
Drop all cached backends (test isolation only).
Each pytest case runs on a fresh event loop; a cached backend holds asyncio primitives bound to the loop it was first awaited on, so leaking one across tests raises "bound to a different event loop" in whichever test comes second.
Source code in src/robotsix_chat/memory/__init__.py
45 46 47 48 49 50 51 52 53 | |