Agents
Streaming answers
An agent writes its answer once; every person, device and other agent reads it live.
An agent writes its answer once. The person who asked reads it on their phone, a teammate on their laptop, a supervisor agent in the background, all live, all from the same stream. If one of them reconnects, it resumes from its last position; if one arrives late, it reads from the start.
Write#
const answer = pulse.stream({ streamId: `answer:${taskId}`, preset: 'llm_agent_run' })try { for await (const text of model.stream(prompt)) await answer.write({ kind: 'text_delta', text }) await answer.end()} catch (err) { await answer.write({ kind: 'text_delta', text: '\n\n(The answer stopped early.)' }) await answer.end()}Hand work to another agent#
Because answers are streams, a second agent can read the first one’s output while it is being written and start on its part early: a reviewer that checks a draft as it forms, or a translator that follows a live answer.
answerStream.subscribe((event) => reviewer.feed(event))Long runs#
Time is free: an agent may stream for an hour, from a queue worker or a serverless job that ends and resumes. The answer counts as one message (again past 10,000 events or 10 MiB). See AI streaming for the details and the AI SDK adapter.