Optional getRetrieve a memory context block to prepend to the system prompt.
The user input for the current turn.
Optional opts: { Retrieval options. tokenBudget caps the memory block size.
Optional tokenAn object whose contextText (when present) is injected as a
system message before the LLM call. Returning null or an object
without contextText skips injection.
Optional observeRecord an observation of a turn exchange.
Invoked twice per turn (role: 'user' with the input, then
role: 'assistant' with the reply) as fire-and-forget. Rejections
are swallowed so memory-backend errors do not break generation.
Whether the content came from the user or assistant.
Plain text content of the turn.
Provider hook interface consumed by
agent()for memory integration.When provided on the agent config,
getContextis called before each LLM generation to inject retrieved memory into the system prompt, andobserveis 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()andagent.session().send()/.stream()all invoke the hooks when the provider is present.