Serialized state has a maximum size of 8 MiB. Saving larger state fails with a
413 Request Entity Too Large error. See Execution limits.Two approaches
Guild offers two state management models:Auto-managed
The runtime handles state automatically. Write a normal
async function with the "use agent" directive — the Babel compiler transforms it into a resumable state machine.Self-managed
You handle state explicitly using
task.save() and task.restore(). More control, but more boilerplate.Auto-managed state
With the"use agent" directive, the Babel compiler transforms your async run function into a state machine that can be paused at any await expression, serialized, and resumed later.
- No
Promise.all,Promise.any, orPromise.raceacrossawaitpoints - Dynamic function references may not survive serialization
- Only code in the agent file is compiled (imports are not traversed)
Self-managed state
WithSelfManagedStateAgent, you define a stateSchema and use task.save() / task.restore() to explicitly persist and retrieve state between tool calls.
- Parallel tool calls via
callTools([...]) - Full control over what gets persisted
- No compiler limitations