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/drafts/activity-events.mdx
+69-38Lines changed: 69 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,20 +61,26 @@ this example UI:
61
61
62
62
### Overview
63
63
64
-
This proposal introduces two new concepts to the AG-UI protocol:
64
+
This proposal introduces new concepts to the AG-UI protocol:
65
65
66
-
1.**ActivityEvent**: A new event type in the event stream
66
+
1.**ActivitySnapshotEvent** and **ActivityDeltaEvent**: Two new event types following the established state management pattern
67
67
2.**ActivityMessage**: A new message type alongside TextMessage, ToolMessage,
68
68
etc.
69
69
70
70
Frameworks may emit ActivityEvents, and frontends can render them inline with
71
71
chat.
72
72
73
-
### New Event: ActivityEvent
73
+
### New Events: ActivitySnapshotEvent and ActivityDeltaEvent
74
+
75
+
Following the established pattern in AG-UI (similar to `StateSnapshotEvent` and `StateDeltaEvent`), activities are represented using two complementary events:
76
+
77
+
#### ActivitySnapshotEvent
78
+
79
+
Provides the complete activity state at a point in time.
74
80
75
81
```typescript
76
-
typeActivityEvent=BaseEvent& {
77
-
type:EventType.ACTIVITY
82
+
typeActivitySnapshotEvent=BaseEvent& {
83
+
type:EventType.ACTIVITY_SNAPSHOT
78
84
/**
79
85
* Unique identifier for the ActivityMessage this event belongs to.
80
86
*/
@@ -84,14 +90,32 @@ type ActivityEvent = BaseEvent & {
84
90
*/
85
91
activityType:string
86
92
/**
87
-
* Snapshot of the full activity state (optional).
93
+
* Complete activity state at this point in time.
94
+
*/
95
+
content:Record<string, any>
96
+
}
97
+
```
98
+
99
+
#### ActivityDeltaEvent
100
+
101
+
Provides incremental updates to the activity state.
102
+
103
+
```typescript
104
+
typeActivityDeltaEvent=BaseEvent& {
105
+
type:EventType.ACTIVITY_DELTA
106
+
/**
107
+
* Unique identifier for the ActivityMessage this event belongs to.
108
+
*/
109
+
messageId:string
110
+
/**
111
+
* Activity type, e.g. "PLAN", "SEARCH", "SCRAPE"
88
112
*/
89
-
snapshot?:Record<string, any>
113
+
activityType:string
90
114
/**
91
-
* Patch to apply to the prior snapshot (optional).
92
-
* Follows JSON Patch semantics.
115
+
* JSON Patch operations to apply to the current activity state.
116
+
* Follows RFC 6902 semantics.
93
117
*/
94
-
patch?:Record<string, any>
118
+
patch:JSONPatchOperation[]
95
119
}
96
120
```
97
121
@@ -103,10 +127,10 @@ Initial activity snapshot:
103
127
{
104
128
"id":"evt_001",
105
129
"ts":1714064100000,
106
-
"type":"ACTIVITY",
130
+
"type":"ACTIVITY_SNAPSHOT",
107
131
"messageId":"msg_789",
108
132
"activityType":"PLAN",
109
-
"snapshot": {
133
+
"content": {
110
134
"tasks": ["check reddit", "search X.com"]
111
135
}
112
136
}
@@ -118,14 +142,16 @@ Incremental update via patch:
118
142
{
119
143
"id":"evt_002",
120
144
"ts":1714064120000,
121
-
"type":"ACTIVITY",
145
+
"type":"ACTIVITY_DELTA",
122
146
"messageId":"msg_789",
123
147
"activityType":"PLAN",
124
-
"patch": {
125
-
"op":"replace",
126
-
"path":"/tasks/0",
127
-
"value":"✓ check reddit"
128
-
}
148
+
"patch": [
149
+
{
150
+
"op":"replace",
151
+
"path":"/tasks/0",
152
+
"value":"✓ check reddit"
153
+
}
154
+
]
129
155
}
130
156
```
131
157
@@ -157,35 +183,37 @@ type ActivityMessage = {
157
183
158
184
TypeScript SDK additions:
159
185
160
-
- New `ActivityEvent` type in `@ag-ui/core`
186
+
- New `ActivitySnapshotEvent` and `ActivityDeltaEvent` types in `@ag-ui/core`
161
187
- New `ActivityMessage` type in message unions
162
188
- Activity renderer registry in `@ag-ui/client`
189
+
- JSON Patch utilities for activity updates
163
190
164
191
Python SDK additions:
165
192
166
-
- New `ActivityEvent` class in `ag_ui.core.events`
193
+
- New `ActivitySnapshotEvent` and `ActivityDeltaEvent` classes in `ag_ui.core.events`
167
194
- New `ActivityMessage` class in message types
168
195
- Activity serialization/deserialization support
196
+
- JSON Patch utilities for activity updates
169
197
170
198
### Integration Impact
171
199
172
-
- **Planning Frameworks**: Can emit ActivityEvents during planning or tool
200
+
- **Planning Frameworks**: Can emit ActivitySnapshotEvent/ActivityDeltaEvent during planning or tool
173
201
execution phases
174
202
- **Workflow Systems**: Can surface step-by-step workflow progress as
175
-
ActivityEvents
176
-
- **Other frameworks**: May emit ActivityEvents freely; AG-UI will serialize
203
+
ActivitySnapshotEvent/ActivityDeltaEvent
204
+
- **Other frameworks**: May emit ActivitySnapshotEvent/ActivityDeltaEvent freely; AG-UI will serialize
177
205
them like other events
178
206
179
207
## Examples and Use Cases
180
208
181
209
### Example 1: Web Search Activity
182
210
183
211
```typescript
184
-
// Agent emits search activity
185
-
agent.emitActivity({
212
+
// Agent emits initial search activity snapshot
213
+
agent.emitActivitySnapshot({
186
214
messageId:"msg_123",
187
215
activityType:"SEARCH",
188
-
snapshot: {
216
+
content: {
189
217
sources: [
190
218
{ name:"Reddit", status:"pending" },
191
219
{ name:"X.com", status:"pending" },
@@ -195,34 +223,37 @@ agent.emitActivity({
195
223
})
196
224
197
225
// Update as search progresses
198
-
agent.emitActivity({
226
+
agent.emitActivityDelta({
199
227
messageId: "msg_123",
200
228
activityType: "SEARCH",
201
-
patch: {
202
-
op: "replace",
203
-
path: "/sources/0/status",
204
-
value: "complete",
205
-
},
229
+
patch: [
230
+
{
231
+
op: "replace",
232
+
path: "/sources/0/status",
233
+
value: "complete",
234
+
}
235
+
],
206
236
})
207
237
```
208
238
209
239
### Use Case: Multi-Step Workflow Visibility
210
240
211
241
A data analysis agent performing multiple steps:
212
242
213
-
1. Loading dataset → ActivityEvent shows progress bar
214
-
2. Cleaning data → ActivityEvent shows rows processed
215
-
3. Running analysis → ActivityEvent shows current computation
0 commit comments