Skip to content

Commit 835c425

Browse files
authored
docs(bb-agent): readme fixes (#14)
1 parent d6d3cb1 commit 835c425

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@aws-blocks/bb-agent": patch
3+
---
4+
5+
docs(bb-agent): document AgentStreamChunk types and Message roles

packages/bb-agent/README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,34 @@ Returned by `stream()`. Provides the Realtime channel and convenience methods:
9696
| `channel` | `Promise<RealtimeChannel>` | Realtime channel handle — `await` it, then call `.subscribe(handler)`. |
9797
| `complete()` | `Promise<AgentStreamChunk>` | Wait for the done chunk (full text + token usage). |
9898

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.
126+
99127
### AgentConfig
100128

101129
| Option | Type | Description |
@@ -630,7 +658,7 @@ const chat = useChat({
630658
resume: (chId, responses, convId) => api.resume(chId, responses, convId),
631659
},
632660
subscribe: async (channelId, handler) => {
633-
const { channel } = await api.getChannel(channelId);
661+
const channel = await api.getChannel(channelId);
634662
return channel.subscribe(handler);
635663
},
636664
onMessagesChange: (msgs) => renderMessages(msgs),

0 commit comments

Comments
 (0)