The durable object
AgentState is a versioned snapshot with only two top-level fields:
Node anatomy
Frontier
The frontier is the set of active graph heads. Appending a normal node removes its parents from the frontier and adds the new node. A new user goal uses the previous frontier as causal context, preserving continuity across turns. The frontier is not “the last message.” Multiple heads can remain active when work branches.Resource versions
When a node hasresourceKey, a later node with the same key automatically includes the previous resource head as a parent.
Semantic memory
The structural kind remainssemantic; its payload carries domain meaning:
memory: durable fact or context;preference: stable user choice or working style;wisdom: reusable evidence-supported lesson;artifact: durable output or artifact reference.
TOOL_CALL or FINAL response, so memory capture does not require a second classification call.
Set allowDynamicNodeTypes: true only when the agent should invent bounded lowercase types. Configured vocabularies are easier to retrieve, render, and govern.
Import validation
The constructor andreset(state) validate:
- snapshot version;
- allowed structural kinds;
- unique IDs;
- parent existence and causal ordering;
- recomputed content identities;
- contiguous sequence values;
- frontier references.
Storage policy
StateWeave does not choose a database. StoreAgentState as one versioned application object, or transform it into your own durable representation while preserving node content and identities.
For browser-owned products, validate size before accepting state back at a server boundary. For sensitive products, encrypt at rest and apply user-level access control. The graph may contain prompts, tool evidence, and model outputs.