feat: Add AG-UI and A2UI protocol support for real-time streaming and rich UIs#988
Open
protolabs42 wants to merge 6 commits intoagent0ai:developmentfrom
Open
feat: Add AG-UI and A2UI protocol support for real-time streaming and rich UIs#988protolabs42 wants to merge 6 commits intoagent0ai:developmentfrom
protolabs42 wants to merge 6 commits intoagent0ai:developmentfrom
Conversation
Implements the AG-UI (Agent-User Interaction Protocol) for real-time Server-Sent Events streaming between Agent Zero and frontend clients. Features: - SSE endpoint at /agui for streaming agent events - Support for both JSON-RPC and flat request formats - Event types: RUN_STARTED/FINISHED, TEXT_MESSAGE_*, TOOL_CALL_*, THINKING_*, STEP_STARTED/FINISHED, STATE_*, CUSTOM - Authentication via Bearer token, API key header, or query param - A2UI action endpoint at /agui/a2ui/action Specification: https://docs.ag-ui.com Co-Authored-By: Sophie <noreply@anthropic.com>
Extension hooks that emit AG-UI events during agent execution: - _15_agui_step_start.py: Emit STEP_STARTED on loop iteration - _15_agui_step_end.py: Emit STEP_FINISHED on loop completion - _15_agui_text_stream.py: Stream TEXT_MESSAGE_CONTENT chunks - _15_agui_text_end.py: Emit TEXT_MESSAGE_END - _15_agui_thinking_stream.py: Stream THINKING_* events - _15_agui_thinking_end.py: Emit THINKING_END - _15_agui_tool_start.py: Emit TOOL_CALL_START/ARGS - _15_agui_tool_end.py: Emit TOOL_CALL_END/RESULT Co-Authored-By: Sophie <noreply@anthropic.com>
Implements the A2UI (Agent-to-UI) protocol v0.8 allowing agents to generate declarative UI components rendered by compatible clients. Package contents: - types.py: Pydantic models for all A2UI messages and components - components.py: Fluent ComponentBuilder API for UI construction - emitter.py: A2UIEmitter for AG-UI transport integration - surfaces.py: SurfaceManager for UI lifecycle management - integration.py: High-level helpers (show_form, show_message, etc.) Standard catalog components (100% coverage): - Content: Text, Icon, Image, Video, AudioPlayer - Layout: Column, Row, List, Card, Tabs, Divider, Modal - Input: Button, CheckBox, TextField, DateTimeInput, MultipleChoice, Slider Extension components beyond standard catalog: - IconButton, Switch, Dropdown, ListTile, Progress indicators, Chip Specification: https://a2ui.org/specification/v0.8-a2ui/ Co-Authored-By: Sophie <noreply@anthropic.com>
Adds the a2ui tool that allows agents to generate interactive UIs: - Methods: show, form, message, progress, confirm, data, delete - Surfaces: @ui (default), @modal, @toast, custom IDs - Data binding with JSON Pointer paths - User action callback handling via extension hook Files: - python/tools/a2ui.py: Tool implementation - python/extensions/a2ui_action/_10_handle_action.py: Action handler - prompts/agent.system.tool.a2ui.md: Tool documentation for LLM Co-Authored-By: Sophie <noreply@anthropic.com>
- Mount /agui endpoint in Starlette routes alongside /mcp and /a2a - Add ag-ui-protocol dependency to requirements.txt Co-Authored-By: Sophie <noreply@anthropic.com>
- docs/agui.md: AG-UI protocol overview, endpoints, event types, usage - docs/a2ui.md: A2UI tool guide, components, surfaces, examples - docs/VERIFICATION_REPORT.md: Spec compliance verification Protocol compliance verified: - AG-UI: 17/17 event types (100%) - A2UI v0.8: 18/18 standard components (100%) Co-Authored-By: Sophie <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for two complementary protocols that enable real-time communication and rich interactive UIs:
AG-UI Protocol (SSE Streaming)
/aguiendpointA2UI Protocol (Rich Interactive UIs)
Architecture
Files Added
AG-UI Layer:
python/api/agui_endpoint.py- SSE endpointpython/helpers/agui_server.py- Queue managementpython/helpers/agui_validation.py- Request validationpython/extensions/*/_15_agui_*.py- 8 streaming hooksA2UI Layer:
python/helpers/a2ui/- Protocol package (types, builder, emitter, surfaces)python/tools/a2ui.py- A2UI tool for agentspython/extensions/a2ui_action/_10_handle_action.py- User action handlerprompts/agent.system.tool.a2ui.md- Tool documentationIntegration:
run_ui.py- Mount/aguiendpointrequirements.txt- Addag-ui-protocoldependencydocs/agui.md,docs/a2ui.md- DocumentationVerification
See
docs/VERIFICATION_REPORT.mdfor full compliance details.Testing
curl -N -X POST http://localhost:port/agui -H "Content-Type: application/json" -d '{"messages":[{"role":"user","content":"Hello"}]}'