datarobot_genai.dragent.memory_space_cache
memory_space_cache
DataRobot MemorySpace-backed KV cache for the agent card registry L2 layer.
Used only on enclave workloads (DR_WORKLOAD_EXTERNAL_URL_HOST +
DR_WORKLOAD_EXTERNAL_URL_PREFIX with WORKLOAD_ID). Other runtimes use
in-process L1 caching only.
Uses the Memory Service light ORM from datarobot.application_utils.persistence
(DRMemorySpace / DRSession / DREvent / DRMemoryServiceClient).
Each cache entry is one session located by a stable DRDeduplicationKey hash
and carrying a single status event whose content is the opaque JSON
payload. set_value patches that event in place instead of appending.
AgentCardCacheSession
Bases: DRSession
Memory Service session model for one agent-card registry L2 cache entry.
Source code in datarobot_genai/dragent/memory_space_cache.py
AgentCardCacheEvent
Bases: DREvent
Single-value status event carrying the opaque JSON cache payload.
Source code in datarobot_genai/dragent/memory_space_cache.py
MemorySpaceKVCache
Store opaque JSON payloads in a DataRobot MemorySpace by logical key.
Source code in datarobot_genai/dragent/memory_space_cache.py
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | |
get_value
async
Return the stored JSON payload for key, or None when missing.
Source code in datarobot_genai/dragent/memory_space_cache.py
set_value
async
Upsert a JSON payload for key.
Source code in datarobot_genai/dragent/memory_space_cache.py
delete_value
async
Remove a cached payload for key when present.
Source code in datarobot_genai/dragent/memory_space_cache.py
is_enclave_l2_workload
Return True when this process can use the registry L2 MemorySpace cache.
registry_cache_deduplication_key
Return the stable deduplication key for an enclave workload's registry L2 space.
get_memory_service_client
try_resolve_memory_space_id
Return the registry L2 MemorySpace ID on enclave workloads, else None.
Creates or adopts the space on first call. Uses WORKLOAD_ID as a
deduplication_key so replicas share one space. No-op when not on an enclave
workload, when credentials are unavailable, or after the first successful
provision in this process.
This is the agent card registry L2 cache, not agent memory
(AGENT_MEMORY_SPACE_ID). Agent memory is provisioned on the control hub
(Pulumi / task deploy-dev) and the Mem0 client talks to that same host.
Other runtimes use in-process L1 caching only.
Import-time bootstrap uses this synchronous helper. Lifespan warmup and
:func:~datarobot_genai.dragent.agent_card_registry.get_default_registry
must call :func:try_resolve_memory_space_id_async to provision — asyncio.run
cannot nest inside an already running event loop.
An id already stored by a prior provision (import bootstrap or the async
helper) is returned synchronously even from a running loop, so YAML parse
and AgentCardRegistry.__init__ can still attach L2 write-behind.
Source code in datarobot_genai/dragent/memory_space_cache.py
try_resolve_memory_space_id_async
async
Async counterpart of :func:try_resolve_memory_space_id.
Use this from a running event loop (lifespan warmup, get_default_registry).
Source code in datarobot_genai/dragent/memory_space_cache.py
try_configure_datarobot_memory_client
Configure the enclave memory client when possible; return False on failure.
Source code in datarobot_genai/dragent/memory_space_cache.py
configure_datarobot_memory_client
Configure the process-global Memory Service ORM client for enclave workloads.
Uses the enclave API gateway (DR_WORKLOAD_EXTERNAL_URL_HOST +
DR_WORKLOAD_EXTERNAL_URL_PREFIX → {host}/api/v2). The ORM client talks
directly to {endpoint}/memory and does not require dr.Client()'s
GET /version/ probe.