Documentation Index
Fetch the complete documentation index at: https://mintlify.com/vercel/eve/llms.txt
Use this file to discover all available pages before exploring further.
defineState is a typed, named slot of durable per-session memory for an agent. Use it when the agent needs to remember something between conversation turns — a running budget, a glossary, a checklist — without standing up an external store. The values survive workflow step boundaries, so they outlast crashes, redeploys, and days-long sessions.
Define a state slot
defineState(name, initial) a stable string name (namespace it to your agent) and an initial function that produces the starting value the first time the slot is read. You get back a StateHandle<T>:
| Method | What it does |
|---|---|
get() | Read the current value. Returns initial() on first access within a context. |
update(fn) | Replace the value with fn(current). |
Read and write state in a tool
agent/lib/budget.ts
agent/tools/spend.ts
get() and update() require an active eve context. Calling them outside tools, hooks, or framework-managed code throws.
Read state in a hook
Because the handle is declared at module scope, the samebudget import works in a hook:
agent/hooks/log-budget.ts
Reset state between turns
State is durable by default and does not reset between turns. If you want a clean slate every turn, overwrite it from a lifecycle hook onturn.started:
agent/hooks/reset-budget.ts
budget handle as the tool, so both read and write the same slot.
State is never shared with subagents
Every subagent starts with its own fresh state, whether it’s a built-inagent copy or a declared specialist. defineState values never cross the parent/child boundary, even when the child is a copy of the same agent.
State vs external storage
defineState holds conversation-scoped working memory that lives and dies with the session:
| Use case | Where to store it |
|---|---|
| Running counters, current plan, what the user told you this conversation | defineState |
| Data that must outlive the session | External store (connection or your own database) |
| Data shared across sessions or users | External store |
| Data that must be queried independently of a turn | External store |
defineState as the agent’s short-term memory — durably persisted for the life of the session, but scoped entirely to it.
What to read next
Hooks
Read and write state from lifecycle event handlers
Tools
Read state inside tool execute handlers
Execution Model & Durability
How step durability keeps state consistent across crashes
TypeScript API Reference
The ctx accessors available alongside state