Streaming
Get events from a run as they happen.
axerity.runs.create() waits for the run to finish. axerity.runs.stream() returns events as the agent works, so you can show progress to your users.
Coming Q4 2026
The SDK ships with AxAgent. The API below may change before launch.
Stream a run
import Axerity from '@axerity/sdk'
const axerity = new Axerity()
const stream = axerity.runs.stream({
agent: agent.id,
input: 'Fix the failing tests in acme/web',
})
for await (const event of stream) {
switch (event.type) {
case 'plan.created':
console.log('plan', event.steps)
break
case 'tool.called':
console.log('→', event.tool, event.input)
break
case 'tool.completed':
console.log('←', event.tool, event.output)
break
case 'text.delta':
process.stdout.write(event.delta)
break
}
}
const run = await stream.finalRun()Events
| Event | When it is sent | Fields |
|---|---|---|
plan.created | The agent has planned the task | steps |
tool.called | The agent calls a tool | tool, input |
tool.completed | A tool call returns | tool, output |
text.delta | The agent writes text | delta |
subagent.started | A subagent starts | subagent.id, subagent.input |
subagent.completed | A subagent completes | subagent.id |
Use event.type to tell events apart. TypeScript narrows the event type in each branch.
Get the final run
After the loop ends, stream.finalRun() returns the same run object that axerity.runs.create() returns.
const run = await stream.finalRun()
console.log(run.text)
console.log(run.usage)