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
Copy file name to clipboardExpand all lines: docs/ai-chat/client-protocol.mdx
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -251,6 +251,45 @@ After sending, subscribe to the output stream again (same URL, same auth) to rec
251
251
On turn 2+, only send the **new** message(s) in the `messages` array — not the full history. The agent accumulates the conversation internally. On turn 1 (or after a continuation), send the **full** message history.
252
252
</Warning>
253
253
254
+
### Tool approval responses
255
+
256
+
When a tool requires approval (`needsApproval: true`), the agent streams the tool call with an `approval-requested` state and completes the turn. After the user approves or denies, send the **updated assistant message** (with `approval-responded` tool parts) back via the same input stream:
257
+
258
+
```bash
259
+
POST /realtime/v1/streams/{runId}/input/chat-messages
260
+
Authorization: Bearer <publicAccessToken>
261
+
Content-Type: application/json
262
+
263
+
{
264
+
"data": {
265
+
"messages": [
266
+
{
267
+
"id": "asst-msg-1",
268
+
"role": "assistant",
269
+
"parts": [
270
+
{ "type": "text", "text": "I'll send that email for you." },
The agent matches the incoming message by its `id` against the accumulated conversation. If a match is found, it **replaces** the existing message (instead of appending). This updates the tool approval state, and `streamText` executes the approved tool on the next step.
288
+
289
+
<Note>
290
+
The message `id` must match the one the agent assigned during streaming. If you're using `TriggerChatTransport`, IDs are kept in sync automatically. Custom transports should use the `messageId` from the stream's `start` chunk.
291
+
</Note>
292
+
254
293
## Pending and steering messages
255
294
256
295
You can send messages to the agent **while it's still streaming a response**. These are called pending messages — the agent receives them mid-turn and can inject them between tool-call steps.
0 commit comments