Memory API¶
Persistent agent memory is the pydantic-ai-harness Memory
capability over a FileStore in the run's workspace. Enable it via
include_memory=True (default) on
create_deep_agent, which builds it with
build_memory_capability.
See Memory for the conceptual overview.
pydantic-deep's own memory API - AgentMemoryToolset, MemoryCapability,
MemoryFile, load_memory, format_memory_prompt - is deprecated: it still
imports, with a DeprecationWarning, and nothing uses it.
build_memory_capability¶
pydantic_deep.features.memory.store.build_memory_capability(*, agent_name, store=None, memory_dir=DEFAULT_MEMORY_DIR, namespace='', max_lines=None, max_tokens=None, max_memory_size=None, pin_marker=None)
¶
The Memory capability one agent remembers with.
Shared by the main agent and every subagent, so their wiring cannot drift.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_name
|
str
|
The agent's own segment in the store; sanitized for the harness. |
required |
store
|
FileStore | None
|
The store to remember in. Agents writing to one directory should
share one: its copies share a lock, which keeps the receipts beside the
notebooks consistent. A new |
None
|
memory_dir
|
str
|
Directory in the run's workspace, when |
DEFAULT_MEMORY_DIR
|
namespace
|
MemoryNamespace
|
A per-tenant segment above the agent's, fixed or resolved per run. The model never sees or chooses it. |
''
|
max_lines
|
int | None
|
Most |
None
|
max_tokens
|
int | None
|
Approximate ceiling on the injected section; likewise. |
None
|
max_memory_size
|
int | None
|
Largest memory file, in characters, the tools will read
or change; the harness default (65,536) when |
None
|
pin_marker
|
str | None
|
Accepted only to warn - the harness has no pinned section. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
A fixed |
MemoryNamespace¶
pydantic_deep.features.memory.store.MemoryNamespace = str | Callable[[RunContext[Any]], str]
module-attribute
¶
A fixed namespace, or one resolved from each run's context - a user id, say.