You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`complete()`|`Promise<AgentStreamChunk>`| Wait for the done chunk (full text + token usage). |
98
98
99
+
### AgentStreamChunk
100
+
101
+
Each chunk published to the Realtime channel has a `type` and type-specific fields:
102
+
103
+
| Type | Fields | Description |
104
+
|------|--------|-------------|
105
+
|`text-delta`|`text: string`| Incremental text token (in `'token'` streaming mode) or full block (in `'block'` mode). |
106
+
|`tool-call`|`toolName: string`, `input: JSONValue`| Agent is calling a tool. |
107
+
|`tool-result`|`toolName: string`, `text: string`| Tool returned a result. |
108
+
|`done`|`text: string`, `usage: TokenUsage`| Agent finished. `text` contains the full response. `usage` has `{ inputTokens, outputTokens, totalTokens }`. |
109
+
|`error`|`error: string`| Agent encountered an error. |
110
+
|`interrupt`|`interrupts: Array<{ id, name, reason }>`| Agent paused for approval. See [Tool Approval](#tool-approval-human-in-the-loop). |
111
+
112
+
### Message Roles
113
+
114
+
Messages stored in conversation history use these roles:
115
+
116
+
| Role | Description |
117
+
|------|-------------|
118
+
|`user`| User message. |
119
+
|`assistant`| Agent response text. |
120
+
|`tool-call`| Record of a tool invocation (stored for audit). |
121
+
|`tool-result`| Record of a tool's return value. |
122
+
|`approval`| User's approval/denial response to an interrupt. |
123
+
|`interrupt`| Agent paused — snapshot of pending interrupts. |
124
+
125
+
The `useChat` hook only surfaces `user`, `assistant`, and `approval` messages to the UI. Use `agent.getConversation()` directly to access the full history including tool-call/tool-result records.
0 commit comments