useEveAgent Reference
This page lists every value, option, and behavior of useEveAgent. Use it when you need exact behavior. For a guided introduction, start with the frontend overview.
React, Vue, and Svelte share the behavior described here. Their pages cover only how each binding exposes it.
Returned state
| Field | What it is |
|---|---|
messages | The current conversation, and your submitted messages before eve confirms them |
status | Outstanding work: "idle", "busy", or "resuming". See Status |
error | The latest session creation, stream, resume, or turn failure |
view | Immutable session snapshot. Query it with functions from eve/events |
agents | Child sessions this store follows. See Child agents |
events | The session's raw stream events, deduplicated and in order |
session | Serializable session cursor: sessionId and streamIndex |
send, respond | Send a message or answers. Resolve with a Delivery receipt when accepted |
cancel | Ask the server to cancel the active turn |
prewarm | Create a session, or prepare an idle one, without starting a turn |
resume | Catch up to the end of the stream. Later following obeys followWhile |
follow | Follow a delivery receipt from this or another store on the same session |
clear, compact | Queue a context change and return its delivery |
end | Retire the server-side session and return its delivery |
newSession | Clear local state and the local session cursor |
About snapshots:
- A snapshot publishes after every event in a recorded stream line has been applied.
- A view you keep, and its observations, never change after later updates.
- Internal tables and preview dictionaries are not public fields.
Options
| Option | Default | Purpose |
|---|---|---|
agent | none | Named agent mounted at /eve/<name>/v1/*. Don't combine with baseUrl |
baseUrl | "" | Where the eve routes are mounted: a same-origin prefix or another origin |
auth, headers | none | Credentials and headers. Function values are resolved before every request, including reconnects |
session | none | An existing ClientSession to bind. It stays owned by your code |
initialSession | none | A saved session cursor to restore |
initialEvents | [] | Saved events to render before catch-up. See Resume a saved session |
resume | false | Replay the session after mount and follow a running turn. Needs initialSession or session |
prewarm | false | Create or prepare the session before the first send. See Prewarming |
optimistic | true | Show submitted messages before eve confirms them |
followAgents | false | Follow child sessions. See Child agents |
followWhile | () => true | Keep the stream open only while this returns true. See Stream lifetime |
prepareSend | none | Adjust each turn just before it is sent, for example to add clientContext |
onEvent, onError, onFinish, onSessionChange | none | See Lifecycle callbacks |
agent, baseUrl, session, initialEvents, initialSession, auth, headers, optimistic, followAgents, and resume are read once, when the hook creates its store. Remount the component, for example with key={chat.id}, to change them. React reads prewarm, followWhile, and the callbacks on every render. Vue and Svelte read prewarm when the binding is created and followWhile from their options object.
Status
| Status | Meaning |
|---|---|
"idle" | Nothing is pending. A turn waiting only on a person can still be open |
"busy" | A command or answer is pending, a followed receipt hasn't settled, or the session has running or queued work |
"resuming" | Catching up on an attached session. Disable sending and answering |
statusdescribes outstanding work, not whether a turn is open. UseactiveTurn(view)fromeve/eventsto decide whether a turn can be steered or cancelled.- A failure sets
errorwithout changingstatus. - After
followWhilecloses the stream,statusreflects the last observed view, not the current server state.
Messages
messages are eve's own EveMessage[]. To pass them to an API typed as AI SDK UIMessage[], adapt them first.
| Part type | What it is |
|---|---|
text | Message text |
reasoning | Model reasoning |
file | An attachment a person sent. url can be absent |
tool | A call the turn made |
interaction | Something the turn asked a person that no call carries: a sign-in, the budget prompt, or a free question |
- Keys: assistant text and reasoning parts carry a stable
idthat survives appends and completion. Usepart.idas the React key. Older events without an ID get a best-effort fallback. User text parts may not have an ID. - Steps: each assistant part carries its turn's
stepIndex. - Follow-ups split replies: each message a person sends is its own bubble, placed where its turn took it in. A message that arrives while the agent works splits the response around it, and both pieces share
metadata.turnId. A single event that combines several deliveries stays one bubble. - Attachments: after
delivery.consumedconfirms an attachment turn, each attachment shows as afilepart withmediaType, optionalfilenameandsize, and aurlonly when the original was browser-resolvable.
Tool parts
A tool part shows a call's shared state, with partial input while it streams.
| Field | What it is |
|---|---|
callId, name | The call, and the tool, agent, or skill it invokes |
kind | tool, agent, skill, or control. Task controls are usually hidden in activity displays |
label | The tool's authored label, its latest output label, or a readable name |
state | streaming while input arrives, then requested, approval, running, blocked, completed, failed, rejected, or cancelled |
inputText | Partial input, only while state is streaming |
input, output, error | Validated input, current or final output, and error details |
interaction | The latest approval or question about the call. It stays open after an answer is submitted, until eve decides it |
- Read outcomes, reasons, and task identities from
call(view, part.callId), not from the part. - A call stays open if your stream stopped following before it finished. Decide what an open call shows after the stream ends.
- A call that a model retry replaced isn't shown; the replacement asks again.
- A delegated call stays
runninguntilcall.settled. Its child's detail is on a separate stream; see Child agents.
Sending
send(message, options)andrespond(answers, options)resolve when the server accepts the request, before the agent replies. They reject if preparation or submission fails. Later execution failures arrive throughview,error, andonError.- The returned
Deliveryhas its ownstream({ signal })andresult({ signal })reads. These can open another HTTP stream and keep working afternewSession()or unmount, so pass a signal that ends with your component. - Headers passed to
send()apply to that request and become the stream's credentials on its next reconnect, until a later send replaces them. - Answers are accepted while other work runs.
Messages during a running turn
turnPolicy | Behavior |
|---|---|
"steer" (default) | Corrects the current turn with the message |
"queue" | Waits for the current turn to finish |
You don't need to pass "steer"; omit turnPolicy unless you want to queue.
Steering timing depends on what the turn is doing:
- Until answer output or a local tool call's input starts streaming, eve interrupts model generation and continues the same turn with the correction.
- Running tools finish and save their results first.
- After the reply starts streaming, a steering message waits until the current step is saved.
- Reasoning and search progress don't count as answer output.
Optimistic messages
With optimistic: true, the default, a submitted message shows in messages before eve confirms it with delivery.consumed.
- The placeholder keeps its message ID when confirmed, so an unrelated or identical message can't replace it.
- A follow-up sent while a turn works appears at the end and stays there once the turn takes it in.
- If the send fails, the placeholder stays in place with
metadata.status: "failed". - Placeholders appear only in
messages;eventsstays the authoritative stream. - While a POST acknowledgement is pending, stream-driven snapshots wait for its identity.
onEventstill receives events.
Prepare each send
prepareSend runs right before each send and returns the turn to send, for example with added clientContext. The optimistic message is already visible while it runs.
Cancelling
cancel()targets the turn this store is observing and keeps the stream attached until the turn ends.- If no turn is active, it waits for a submission that was pending when you called it, including preparation, session creation, and POST acceptance, then cancels that turn. It never stops an unrelated later turn.
- It doesn't withdraw a queued message. If the message never reaches a running turn,
cancel()does nothing. An idlecancel()doesn't arm a future request. - Cancellation is cooperative: a turn can finish before it takes effect.
- Unmounting or closing the page disconnects the local stream but doesn't cancel the turn. Call
cancel()first when the user wants to stop it.
Stream lifetime
By default, the hook keeps one stream open across turns and idle periods, so replies, authorization updates, and turns started elsewhere all arrive as they happen.
- A turn settling doesn't close the connection.
- The stream reconnects from its cursor after a disconnect and when the server's renewable 60-second lease ends. Renewal doesn't start a turn or clear UI state.
- Unmounting or
newSession()closes the local stream without cancelling the session on the server.
Close the stream when idle
followWhile(view) closes the stream when it returns false at a complete line boundary, after catch-up and any followed receipt. Pair it with follow() to stream only while the agent works. This sidebar shares a stable ClientSession with the main chat:
followWhilecan close the stream while a turn is active or waiting on a person. The UI then stays at its last observed state until a command orfollow()reopens it.- To close only between turns, pass
(view) => !idle(view) || activeTurn(view) !== undefined. - A closed stream can't see new activity. Send a command, call
resume()orfollow(), or keep the default when other sources can start work.
Follow a receipt
follow(receipt)tracks an accepted receipt until it finishes, even if the stream caught up before the server admitted it.- Pass only receipts from
send,respond,clear,compact, orendon the same session. A receipt the stream never admits keeps the store"busy"until the session ends or you callnewSession(). follow()doesn't create a session or grant access.- Limit retries after stream errors, and resolve authorization failures before retrying.
Prewarming
Prewarming creates the session before the first message so the first reply starts sooner.
- Default off. The first send creates the session. Turn it on only after your auth, headers, and any chat-record binding are ready.
- React:
prewarm: trueprepares on mount, after eachnewSession(), and when the option changes fromfalsetotrue, including for a restored session. - Vue and Svelte: the option is read when the binding is created. Call
prewarm()when typing starts. - Typing bursts: call
prewarm()once when a burst begins, with your own cooldown if you retry during long drafts. eve shares concurrent calls; it doesn't watch inputs or poll deployments.
What prewarming does
- It starts the workflow and its inbox, then waits before session hooks or dynamic definitions run.
- It starts the agent's sandbox in the background. The first turn doesn't wait for it; only a tool or hook that uses the sandbox does. If startup fails, the first turn that needs the sandbox starts it.
- The first message passes through the channel's
onMessagehook and supplies identity and context for initialization and the first turn. - The session timeout starts at creation, so an unused prewarmed session can expire. eve deletes its sandbox when it ends.
prewarm()resolves when the server accepts creation, without waiting for initialization. The composer stays"idle", andprepareSenddoesn't run.- A concurrent
send()waits for creation to be accepted, and your abort signal cancels the wait.
Existing sessions on Vercel
For an existing idle session, prewarm() can move it to the deployment that accepted the request, ahead of the next send(). The ID, history, stream, and expiry stay the same, and no model call runs.
- A session already running on that deployment isn't woken.
- Active turns are never interrupted. A turn can finish before the move, and a queued message takes priority.
- A session with pending tasks or input requests can skip the move.
- Sessions from eve versions without this support, or on workflow backends without deployment routing, aren't moved.
- A production alias targets its current deployment and a preview alias its preview. Requests pinned to an immutable deployment can't discover a newer one.
- In local development,
prewarm()can create a session but doesn't move one. client.sessions.attach(sessionId).prewarm({ signal })returnsready,accepted,unsupported, orno_active_session.acceptedmeans the request was saved, not that the move finished. It never replaces an expired session.send()keeps its own retries if the move is unavailable or unfinished.
Prewarm failures
- A failed move of an existing session rejects the explicit call without setting
erroror blockingsend(). - A failed create sets
errorand callsonErrorwhen no send is waiting. A waiting send can fall back to creating the session with its message. - After creation, initialization failures arrive on the stream during the first turn.
- React doesn't retry a failed prewarm on unrelated renders. Recover by calling
prewarm(), toggling the option fromfalsetotrue, callingnewSession(), or sending a message.
Start over
| Command | Effect |
|---|---|
newSession() | Clears the local conversation and reuses the hook. The old session keeps running on the server |
end() | Retires the server-side session and returns its delivery |
After end(), call newSession() to clear the retired conversation. With prewarm on, that prepares the next session; otherwise the next send creates it. While a send or prewarm() is still creating the session, end(), clear(), and compact() wait for it and then act on that session. A session you passed in stays yours: prewarming and newSession() never replace it.
Resume a saved session
Pass a saved cursor and events with resume: true:
Saved events
initialEventsmust be an ordered prefix of the same session's stream. Its end doesn't have to match where the stream resumes.- Catch-up starts after the source lines your events cover. Coverage uses line positions, not event counts.
- Keep reader metadata unchanged.
meta.nextcan record source lines that produced no events. - The
initialSessioncursor alone never extends coverage. A partial line is replayed from its start. - Each event's
meta.positionis stable, and the store drops positions it already applied. An overlapping replay renders once, andonEventfires only for new events. session.streamIndexandposition(view)both track the covered prefix.
Catch-up
- While catching up,
statusis"resuming". Render saved messages, but disable sending and answering, and don't show cancel or progress controls. resume()resolves when catch-up reaches the end of the stream, even while a turn runs.- Afterward,
statusis"busy"for running or queued work, or"idle"for a session with nothing running or a turn waiting only on a person. - The connection then stays open to follow the session, unless
followWhilecloses it. - A terminal session failure sets
error.
Lifecycle callbacks
| Callback | When it fires |
|---|---|
onEvent(event) | For each stream event as it arrives |
onError(error) | When session creation, streaming, resume, or a live turn fails, or a prewarm fails with no send waiting. Restored historical failures don't fire it |
onFinish(snapshot) | When a live turn ends, after its last events are visible. Catch-up never fires it |
onSessionChange(session) | When a session is created, its cursor advances, or newSession() clears it |
To read the result of one delivery, use receipt.result() instead of onFinish. A delivery can finish while its turn still waits for input.
Interactions
Approvals, questions, sign-ins, and budget prompts are requests for input, which the API calls interactions. Read them with interaction(view, id), interactions(view), or openInteractions(view) from eve/events.
- A request stays
openuntil eve decides it. Submitting an answer doesn't end it; the stream'sinteraction.settledevent does. - A tool part's
stateis the call's state, not the decision. A call can becancelledwhile its approval was never answered.
outcome | Meaning |
|---|---|
accepted | A person approved or answered it |
declined | A person declined |
withdrawn, interrupted, abandoned, expired, invalid, failed | No decision. The request ended another way, such as a cancelled turn or a message sent while a sign-in was pending |
Show "Approved" or "Denied" only for accepted and declined. For any other outcome, show the outcome itself. Keep a default branch: later releases can add outcomes.
Use eve's answers
Read session state from view with selectors from eve/events, instead of scanning events or keeping your own copy. Session views & selectors maps common questions to the right selector.
For one request's status, outcome, reply, interactions, and error, use delivery.result(). It is scoped to one delivery. Scanning the events in a delivery's interval isn't: a queued message's interval starts while the earlier turn still runs, so it includes that turn's turn.settled.
To resume a saved chat, use the hook's session, position(view), or session.snapshot(), never an event count. See Resume a saved session for the client cursor contract.
Outside the store:
foldEvents(view, events), starting fromemptySessionView, folds received events by whole line. It returns a new view and holds unfinished lines until they complete.callPreview(view, callId)andcontentPreviews(view)show transient progress.conversationOf(events)fromeve/clientrenders a saved log.
Child agents
A delegated call's detailed progress lives on the child session's stream, not in the root messages. Pass followAgents to observe recorded children, including children opened inside workflow tools:
- The predicate is synchronous. An excluded child's descendants aren't discovered. Root depth is zero.
- Each
agents[sessionId]describes one opening, with anownernaming its call or task. Itsobservation.conversationhas its ownagents,messages, andview. - Calls that continue a task reuse its child conversation.
- Read a call's or delivery's final result for its outcome, not the child's latest message.
- Requests the parent relays are the ones people answer. Don't render a second set of controls from child observations.
Limits
| Limit | Value |
|---|---|
| Child observations per root | 128, reset by newSession() |
| Depth | 8 |
| Simultaneous descendant reads | 8, independent of the root stream |
| Read length | Until the captured tail, or 10 seconds |
| Refresh delay after catching up | 1 to 10 seconds |
These limits don't affect execution or the root transcript. The policy is read at store creation and evaluated once per relationship at each reachable depth. When two paths reach the same session, the store shares one observation.
Observation status
| Status | Meaning |
|---|---|
"not-followed" | Following is off, or reason names a predicate, limit, or cycle |
"queued" | Waiting for a read slot |
"following" | Reading. Silence doesn't mean the child is done |
"caught-up" | Reached the tail captured for this read. The child may still be working |
"interrupted" | A retryable read failure, or the observation was detached |
"unavailable" | History can't be read now. reason distinguishes authorization, expiry, unsupported readers, and transport |
- Every status except
"not-followed"exposesposition,caughtUp, andconversation, which can be empty before the first read. caughtUpdescribes the tail when that read opened, not that execution finished.- Each observation's
keyidentifies the session within this store's authorized reader scope. Equal IDs from different remote namespaces aren't merged. - Cursors are per session.
- Root call results,
status,resume(),events, and callbacks describe the root session only; child failures stay on their observations.
Activity from one call
When several calls share a child, agentCallActivity(state, callId) from eve/client shows what one call caused:
- A delivery is
"unseen"until this reader reads the child's admission, then"admitted","consumed", or"settled". - Several calls can reach one turn. Each turn lists the other calls it answered in
sharedWith, so render it once. "unlinked"means the parent recorded no delivery, as for a call that sent nothing or reached a remote agent on an earlier protocol.
Without the hook
- For headless capture, use
SessionStore.observe(). Archive observed prefixes with their per-session cursors in your own versioned schema, and keep earlier archives when history expires. - If you read child streams yourself, attribute work with the parent's
child.sentevents. Each one names thecallIdand thechildDeliveryIdon the child's stream. Don't countdelivery.consumedon the child: answers to the child's questions are deliveries too. - With your own session, pass a
child.openedevent tosession.agent()and follow the child withstream(). It reads local and remote children through the parent. See What the parent sees.