datarobot_genai.dragent.plugins.streaming_memory_agent
streaming_memory_agent
Streaming counterpart to NAT's auto_memory_agent.
NAT's upstream auto_memory_agent calls inner_agent_fn.ainvoke(...) in
its inner_agent_node, which collapses the inner stream into a single
string. For AG-UI consumers that means only one
CustomEvent("DEFAULT_NAT_RESPONSE") ever reaches the frontend; the token
deltas and tool-call deltas the inner agent's stream_fn would have
emitted are lost.
streaming_memory_agent performs the same mem0 capture/retrieve operations
(save user message → retrieve and inject as system context → save AI
response) but astreams the inner agent and yields its native
DRAgentEventResponse events straight through, so token deltas and
tool-call deltas surface as proper AG-UI TextMessage* / ToolCall*
events.
Registered with register_per_user_function so the wrapper itself builds
lazily inside a PerUserWorkflowBuilder. Without that, the wrapper's
builder.get_function(inner_agent_name) call would run at workflow-build
time and miss per-user inner agents (which are built lazily on first user
invocation). Per-user inner agents end up in the per-user builder's cache
before the workflow is built, and shared inner agents still resolve via
fall-through to the shared builder — both cases work transparently.
The configuration surface (memory_name, inner_agent_name,
save_user_messages_to_memory, retrieve_memory_for_every_response,
save_ai_messages_to_memory, search_params, add_params) is inherited
from upstream AutoMemoryAgentConfig so the two wrappers can be swapped
without reauthoring workflow.yaml. When the referenced memory backend is
unconfigured (dr_mem0_memory with no credentials), the wrapper passthroughs
to the inner agent without memory operations.
StreamingMemoryAgentConfig
Bases: AutoMemoryAgentConfig
Streaming, per-user variant of auto_memory_agent.
Inherits memory_name, inner_agent_name,
save_user_messages_to_memory, retrieve_memory_for_every_response,
save_ai_messages_to_memory, search_params, and add_params
from :class:AutoMemoryAgentConfig. Only the _type discriminator
differs, so a workflow can switch between the two by renaming _type.
When the referenced memory backend is unconfigured, the wrapper passthroughs
to the inner agent without memory capture or retrieval.
Source code in datarobot_genai/dragent/plugins/streaming_memory_agent.py
streaming_memory_agent
async
streaming_memory_agent(config: StreamingMemoryAgentConfig, builder: Builder) -> AsyncGenerator[Any, None]
Build the streaming memory agent workflow.
Source code in datarobot_genai/dragent/plugins/streaming_memory_agent.py
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 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |