Streaming, cancellation and recovery
Observe run state and distinguish stopping observation from cancelling durable work.
Read the run, not just the model text
startRun returns a handle with wait, getSnapshot and timeline reads. Model output is only one event stream; approvals, suspension, failure and terminal publication affect the operation's outcome.
const run = await agent.startRun("Summarize the document");
const snapshot = await run.getSnapshot();
const timeline = await run.readTimeline();
const result = await run.wait();Transport these observations through an application-owned authenticated endpoint. A browser must not receive unrestricted store access or another user's run identity.
Cancel with explicit ownership
await run.cancel("User cancelled", "authenticated-user");The requester above must be established by the host, not copied from untrusted client input. A queued control request is not proof that every binding stopped or an external side effect rolled back.
Resume only with the exact persisted run, compatible bindings and valid approval/checkpoint evidence. Keep ambiguous Tool effects fenced for application reconciliation. Reconnecting a browser should attach to existing work, not start it again.