TypeScript SDK · Causal Weave v3
A graph is the memory.
StateWeave is a low-level agent primitive. It stores what happened as an immutable causal graph, then compiles only the relevant part into each model prompt.
StoreAppend causal nodes
SelectCompile a bounded view
ActCall a normal model
CommitRecord evidence and answer
AgentState: goals, inferences, tool evidence, resource versions, semantic memory, errors, and answers connected by direct dependencies.
A provider still receives a linear token sequence. Transformers require one. StateWeave treats that sequence as a temporary view of state, not as state itself.
Core invariant
The runtime knows the read set because it builds the prompt. The model does not draw edges or emit graph operations. It returns an ordinary A model action’s parents are exactly the graph nodes selected for that inference.
TOOL_CALL or FINAL; StateWeave records the lineage.
Why this primitive exists
Long-running agents need two things that transcripts conflate:- A complete record. What was observed, changed, superseded, rejected, and concluded?
- A small working view. What does this inference need now?
The graph is truth. The prompt is a view.
What StateWeave owns
StateWeave owns
Causal nodes, projection, action parsing, tool evidence, state validation, and run traces.
You own
The model adapter, tools, persistence, product policy, user interface, and deployment.
The provider sees
The bounded compiled prompt and provider-level system instruction for the current inference.
Read this manual
The shortest path is:- Run the quickstart.
- Read Why StateWeave.
- Follow one turn through How it works.
- Use the complete example as an integration template.
Agent.