SDK Examples
Example: Live UI
Render Agent output in real time with session.subscribe()
Example: Live UI
const unsubscribe = session.subscribe((event) => {
if (event.type === "text-delta") {
render(event.text);
}
});
const turn = await session.prompt({
query: "Continue",
});
await turn.finished;
unsubscribe();If you also want to show tool activity, handle:
tool-calltool-resultturn-finish
This pattern is especially good for terminal live output and web-based real-time chat UI.