Skip to content

Commit 954b18a

Browse files
committed
wip
1 parent 37d9691 commit 954b18a

File tree

9 files changed

+1921
-0
lines changed

9 files changed

+1921
-0
lines changed

docs/docs.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@
4545
"concepts/tools"
4646
]
4747
},
48+
{
49+
"group": "Draft Changes",
50+
"pages": [
51+
"drafts/overview",
52+
"drafts/activity-events",
53+
"drafts/reasoning",
54+
"drafts/serialization",
55+
"drafts/multimodal-messages",
56+
"drafts/interrupts",
57+
"drafts/generative-ui",
58+
"drafts/meta-events"
59+
]
60+
},
4861
{
4962
"group": "Tutorials",
5063
"pages": ["tutorials/cursor", "tutorials/debugging"]

docs/drafts/activity-events.mdx

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
---
2+
title: Activity Events
3+
description: Proposal for representing ongoing agent progress between chat messages
4+
---
5+
6+
# Activity Events Proposal
7+
8+
## Summary
9+
10+
### Problem Statement
11+
Users want to render "activity" updates inline with chat, not just at run start or end. Currently, there's no standardized way to represent ongoing agent progress between chat messages.
12+
13+
### Motivation
14+
AG-UI is extended with **ActivityEvents** and **ActivityMessages** to represent ongoing agent progress in between chat messages. This allows frameworks to surface fine-grained activity updates chronologically, giving users immediate visibility into what an agent is doing without waiting for the next message or run boundary.
15+
16+
## Status
17+
18+
- **Status**: Draft
19+
- **Author(s)**: AG-UI Team
20+
21+
## Background
22+
23+
Users want real-time visibility into agent activities as they happen. Consider this example UI:
24+
25+
```
26+
+------------------------------------------------------------+
27+
| I will search the internet for relevant information | <- TextMessage
28+
+------------------------------------------------------------+
29+
+------------------------------------------------------------+
30+
| ✓ checking reddit | <- ActivityMessage
31+
| searching X.com... |
32+
+------------------------------------------------------------+
33+
```
34+
35+
### Use Cases
36+
37+
- **Workflows**: Step-by-step progress through workflow execution
38+
- **Planning**: Intermediate planning or tool use visibility
39+
- **Custom frameworks**: Signals representing ongoing work in any agent system
40+
41+
## Challenges
42+
43+
- **Flexibility**: Must handle arbitrary activity data from different frameworks
44+
- **Serializability**: Events must be replayable and rehydrated for session recovery
45+
- **Extensibility**: Developers should define custom renderers per activity type, with a generic fallback
46+
- **Chronology**: Activities must interleave naturally with chat and run events
47+
48+
## Detailed Specification
49+
50+
### Overview
51+
52+
This proposal introduces two new concepts to the AG-UI protocol:
53+
1. **ActivityEvent**: A new event type in the event stream
54+
2. **ActivityMessage**: A new message type alongside TextMessage, ToolMessage, etc.
55+
56+
Frameworks may emit ActivityEvents, and frontends can render them inline with chat.
57+
58+
### New Event: ActivityEvent
59+
60+
```typescript
61+
type ActivityEvent = BaseEvent & {
62+
type: EventType.ACTIVITY
63+
/**
64+
* Unique identifier for the ActivityMessage this event belongs to.
65+
*/
66+
messageId: string
67+
/**
68+
* Activity type, e.g. "PLAN", "SEARCH", "SCRAPE"
69+
*/
70+
activityType: string
71+
/**
72+
* Snapshot of the full activity state (optional).
73+
*/
74+
snapshot?: Record<string, any>
75+
/**
76+
* Patch to apply to the prior snapshot (optional).
77+
* Follows JSON Patch semantics.
78+
*/
79+
patch?: Record<string, any>
80+
}
81+
```
82+
83+
#### Example Events
84+
85+
Initial activity snapshot:
86+
```json
87+
{
88+
"id": "evt_001",
89+
"ts": 1714064100000,
90+
"type": "ACTIVITY",
91+
"messageId": "msg_789",
92+
"activityType": "PLAN",
93+
"snapshot": {
94+
"tasks": ["check reddit", "search X.com"]
95+
}
96+
}
97+
```
98+
99+
Incremental update via patch:
100+
```json
101+
{
102+
"id": "evt_002",
103+
"ts": 1714064120000,
104+
"type": "ACTIVITY",
105+
"messageId": "msg_789",
106+
"activityType": "PLAN",
107+
"patch": {
108+
"op": "replace",
109+
"path": "/tasks/0",
110+
"value": "✓ check reddit"
111+
}
112+
}
113+
```
114+
115+
### New Message: ActivityMessage
116+
117+
```typescript
118+
type ActivityMessage = {
119+
id: string
120+
role: "activity"
121+
activityType: string
122+
/**
123+
* Finalized activity content as of compaction.
124+
*/
125+
content: Record<string, any>
126+
}
127+
```
128+
129+
### Rendering Strategy
130+
131+
- **Generic renderer**: Displays raw snapshot/patch as JSON or formatted text
132+
- **Custom renderer**: Developers can register a renderer per `activityType`:
133+
- `"PLAN"` → Interactive checklist component
134+
- `"SEARCH"` → Live status with progress indicators
135+
- `"WORKFLOW"` → Step-by-step workflow visualization
136+
137+
## Implementation Considerations
138+
139+
### Client SDK Changes
140+
141+
TypeScript SDK additions:
142+
- New `ActivityEvent` type in `@ag-ui/core`
143+
- New `ActivityMessage` type in message unions
144+
- Activity renderer registry in `@ag-ui/client`
145+
146+
Python SDK additions:
147+
- New `ActivityEvent` class in `ag_ui.core.events`
148+
- New `ActivityMessage` class in message types
149+
- Activity serialization/deserialization support
150+
151+
### Integration Impact
152+
153+
- **Planning Frameworks**: Can emit ActivityEvents during planning or tool execution phases
154+
- **Workflow Systems**: Can surface step-by-step workflow progress as ActivityEvents
155+
- **Other frameworks**: May emit ActivityEvents freely; AG-UI will serialize them like other events
156+
157+
## Breaking Changes
158+
159+
None. This is an additive change that maintains backward compatibility.
160+
161+
## Examples and Use Cases
162+
163+
### Example 1: Web Search Activity
164+
165+
```typescript
166+
// Agent emits search activity
167+
agent.emitActivity({
168+
messageId: "msg_123",
169+
activityType: "SEARCH",
170+
snapshot: {
171+
sources: [
172+
{ name: "Reddit", status: "pending" },
173+
{ name: "X.com", status: "pending" },
174+
{ name: "Google", status: "pending" }
175+
]
176+
}
177+
})
178+
179+
// Update as search progresses
180+
agent.emitActivity({
181+
messageId: "msg_123",
182+
activityType: "SEARCH",
183+
patch: {
184+
op: "replace",
185+
path: "/sources/0/status",
186+
value: "complete"
187+
}
188+
})
189+
```
190+
191+
### Use Case: Multi-Step Workflow Visibility
192+
193+
A data analysis agent performing multiple steps:
194+
1. Loading dataset → ActivityEvent shows progress bar
195+
2. Cleaning data → ActivityEvent shows rows processed
196+
3. Running analysis → ActivityEvent shows current computation
197+
4. Generating report → ActivityEvent shows sections completed
198+
199+
Each step appears inline with chat, giving users real-time feedback.
200+
201+
## Testing Strategy
202+
203+
- Unit tests for ActivityEvent serialization/deserialization
204+
- Integration tests with mock frameworks emitting ActivityEvents
205+
- E2E tests in AG-UI Dojo demonstrating activity rendering
206+
- Performance benchmarks for high-frequency activity updates
207+
208+
## Open Questions
209+
210+
1. Should we enforce a schema for common activity types (e.g., standardized "PLAN" format)?
211+
2. How should activities behave across run boundaries?
212+
3. Should there be a maximum number of patches before requiring a new snapshot?
213+
4. How do activities interact with message editing/regeneration?
214+
215+
## References
216+
217+
- [JSON Patch RFC 6902](https://tools.ietf.org/html/rfc6902)
218+
- [AG-UI Events Documentation](/concepts/events)
219+
- [AG-UI Messages Documentation](/concepts/messages)

0 commit comments

Comments
 (0)