Cross-run facts, message threads, namespaces, and the Effect store layer.
Memory persists state across runs. Task outputs are per-run; memory is
per-namespace and survives every workflow execution. The store keeps two kinds
of state: namespaced facts (JSON values with optional TTL) and ordered
message threads.All memory values and non-generic types are re-exported from the
smithers-orchestrator facade, which is canonical. The
smithers-orchestrator/memory subpath exports the same surface.
import { createMemoryStore, createMemoryLayer, MemoryService, Summarizer, TokenLimiter, TtlGarbageCollector, namespaceToString, parseNamespace,} from "smithers-orchestrator";import type { MemoryNamespace, MemoryNamespaceKind, MemoryFact, MemoryThread, MemoryMessage, MemoryStore, MemoryServiceApi, MemoryProcessor, MemoryProcessorConfig, MemoryLayerConfig, TaskMemoryConfig, SemanticRecallConfig, MessageHistoryConfig,} from "smithers-orchestrator";
WorkingMemoryConfig<T> is generic over a Zod schema and is documented inline
below rather than imported. The memory prop on Task is returned by the
factory, not imported; see Memory for the declarative
<Task memory={...}> metadata.
A MemoryNamespace scopes everything you store. Pick the kind to match the
lifetime of the data, and the id to identify the specific workflow, agent, or
user.
Build a MemoryStore over a Drizzle SQLite handle. Synchronous. Create one at
module scope and reuse it across tasks rather than re-opening the database in
every task body.
function createMemoryStore(db: BunSQLiteDatabase<any>): MemoryStore;
The Promise-based read/write surface. Every method has an Effect-returning twin
(getFactEffect, setFactEffect, listThreadsEffect, deleteMessagesEffect,
and so on) with the same arguments, for use inside an Effect pipeline.
An Effect Context.Tag whose service value is a MemoryServiceApi. It exposes
the same operations as the store, but every method returns
Effect.Effect<T, SmithersError> instead of a Promise. The underlying store
is reachable via .store.
Build the Effect Layer that provides MemoryService. Pass it a
MemoryLayerConfig carrying the Drizzle database; provide the resulting layer
to any Effect that depends on MemoryService.
function createMemoryLayer( config: MemoryLayerConfig,): Layer.Layer<MemoryService, never, never>;
Compresses older messages in each thread into a single system summary
message, keeping the two most recent. agent is any
{ run: (prompt: string) => Promise<unknown> }; its output text becomes the
summary.
TaskMemoryConfig is the shape of the memory prop on Task. It is preserved
as task metadata for runtimes and integrations that layer memory behavior onto
task execution; the store APIs above are the current public read/write surface.
Namespaces are stored as strings. These two helpers round-trip a
MemoryNamespace to and from its canonical kind:id form, percent-encoding
: and % in the id.