Setup
List agents
Create a session
Send a message
Stream events
Three options for receiving events:offset to track the last seen sequence number and resume from where you left off.
Handling Events
Bare minimum
Handle item lifecycle plus turn lifecycle to render a basic chat:- Use
turnInProgressfor turn-level UI state (disable send button, show global “Agent is responding”, etc.). - Use
item.status === "in_progress"for per-item streaming state.
Extra events
Handle these for a complete implementation:Content parts
Each item hascontent parts. Render based on type:
Handling Permissions
Whenpermission.requested arrives, show an approval UI:
Handling Questions
Whenquestion.requested arrives, show a selection UI:
Testing with Mock Agent
Themock agent lets you test UI behaviors without external credentials:
help to see available commands:
| Command | Tests |
|---|---|
help | Lists all commands |
demo | Full UI coverage sequence with markers |
markdown | Streaming markdown rendering |
tool | Tool call + result with file refs |
status | Status item updates |
image | Image content part |
permission | Permission request flow |
question | Question request flow |
error | Error + unparsed events |
end | Session ended event |
echo <text> | Echo text as assistant message |