Interface: AgentMemoryProvider
Defined in: packages/agentos/src/api/agent.ts:126
Provider hook interface consumed by agent() for memory integration.
When provided on the agent config, getContext is called once per turn,
before its first model call, to retrieve memory for the turn, and
observe is called after each turn to encode the exchange for future
recall. Both hooks are optional — implementations may choose to provide
read-only or write-only memory behavior.
Auto-wires on every agent call path as of AgentOS 0.2.0: direct
agent.stream() / .generate() and agent.session().send() / .stream()
all invoke the hooks when the provider is present.
Properties
getContext()?
optionalgetContext: (text,opts?) =>Promise<{contextText?:string;items?:MemoryRecallItem[]; } |null>
Defined in: packages/agentos/src/api/agent.ts:139
Retrieve the memory recalled for a turn. It is called once per turn.
Parameters
text
string
The user input for the current turn.
opts?
Retrieval options. tokenBudget caps the memory block size;
context says which session, user and agent the turn serves.
context?
tokenBudget?
number
Returns
Promise<{ contextText?: string; items?: MemoryRecallItem[]; } | null>
The recall, which is sent to the model as a block of data in a
user-role message before the turn's message, not as instructions.
items is the recalled entries as records; a provider that returns
contextText alone has that text sent as one record. Returning null,
or neither, skips the block.
observe()?
optionalobserve: (role,text,context?) =>Promise<void>
Defined in: packages/agentos/src/api/agent.ts:157
Record an observation of a turn exchange.
Invoked once per side of a turn that was answered (role: 'user' with
the input, then role: 'assistant' with the reply) as fire-and-forget:
the turn never waits for it, and a throw or a rejection never changes the
turn's result. A failure is logged as a memory.hook_failed event on the
provider's first failure and then at its 10th, 100th, 1000th and so on.
Parameters
role
Whether the content came from the user or assistant.
"user" | "assistant"
text
string
Plain text content of the turn.
context?
Which session, user and agent the turn serves.
Returns
Promise<void>