ExAgent. Chat. AISDK
(ExAgent v3.0.0)
View Source
Pure encoder for the Vercel AI SDK 7 UI Message Stream Protocol v1.
Stability — Candidate.
Start an encoder with new/3 using an authorized chat view. Write headers/0
on the response and feed ordered Server events from the start of the root run
to push/2 until finished?/1. For a resumed C7 attempt, set :resume_after
to the preceding pause cursor and replay the retained run events from the
first attempt. The assistant message ID is the Server run ID in every attempt.
The encoder streams root answer text and sends narration through the
transient data-exagent-commentary part. Its ID is the Server event cursor.
A client accumulating onData deltas can use that ID to deduplicate a full
replay. Protected drafts are hidden.
The encoder replaces provisional text with the accepted output and keeps
tool and reasoning parts. Tools use stable Server call references. A review
can create a tool part with withheld input before execution. The encoder
also sends data-exagent-status for C7 controls and cancellation.
The host owns HTTP, admission, review, tool execution and cancellation.
See the AI SDK stream protocol.
Summary
Functions
Whether the encoder has written the terminal marker.
Response headers for the UI Message Stream Protocol.
Initialize a stream through a root attempt of the observed owner.
Consume an event and return the encoder and any complete SSE frames.
Admit a request from the SDK client's regenerate() on an authorized source.
Types
Functions
Whether the encoder has written the terminal marker.
Response headers for the UI Message Stream Protocol.
@spec new(ExAgent.Chat.t(), String.t(), keyword()) :: t()
Initialize a stream through a root attempt of the observed owner.
On C7 resume, pass the cursor of the preceding confirmed :run_paused
event as :resume_after. Feed the full retained event sequence from the
first :run_started to rebuild the SDK message. Earlier pauses keep the
stream open and earlier tool results remain in the message. The next
pause or terminal event closes the stream. If the run prefix is unavailable,
reload the authorized chat snapshot.
:reasoning defaults to false. Pass a redactor
fn :reasoning_summary, text -> {:ok, reviewed_text} | :drop end for
bounded provider summaries on unguarded turns. The UTF-8 result must
fit 4096 bytes as JSON.
@spec push(t(), ExAgent.Event.t()) :: {t(), iodata()}
Consume an event and return the encoder and any complete SSE frames.
@spec regenerate(GenServer.server(), map(), keyword()) :: {:ok, map()} | {:error, term()}
Admit a request from the SDK client's regenerate() on an authorized source.
The encoder's assistant message ID is the root run ID. The host can set
:at explicitly when its UI uses other IDs. The SDK's messages payload
has no authority over the fork. Options and the reply follow
ExAgent.Server.regenerate/2. Stream the returned run on the branch owner.