Add AG-UI Protocol Plugin for BotSharp #2
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.
Overview
This PR implements a complete AG-UI (Agent-User Interaction) protocol plugin for BotSharp, enabling standardized event-based communication between AI agents and user-facing applications. AG-UI is an open, lightweight protocol that allows seamless integration with frontend frameworks like CopilotKit and other AG-UI-compatible applications.
What is AG-UI?
AG-UI is an event-based protocol that standardizes how AI agents connect to user interfaces. It sits alongside other agent protocols:
Implementation
Core Components
Plugin Structure:
AgUiPlugin.cs- Plugin registration and metadataAgUiController.cs- SSE streaming endpoint at/ag-ui/chatEvent Types Implemented:
text_message_start/content/end- Streaming assistant responsestool_call_start/args/end- Function/tool invocations with argumentstool_call_result- Tool execution resultsstate_snapshot- Conversation state synchronizationcustom- Custom eventserror- Error handlingIntegration with BotSharp
The plugin integrates seamlessly with existing BotSharp services:
Advanced Parameter Handling
The implementation carefully handles all AG-UI parameters as specified:
State Management:
{ "state": { "user_name": "Alice", "preferences": {"theme": "dark"} } }Converted to BotSharp conversation states for persistence across turns.
Context Awareness:
{ "context": [ { "name": "document", "description": "Current document being edited", "value": "Document content..." } ] }Stored as
context_{name}in conversation state, accessible to agents.Tool Definitions:
{ "tools": [ { "name": "search_knowledge", "description": "Search the knowledge base", "parameters": { "type": "object", "properties": {"query": {"type": "string"}} } } ] }Serialized and stored for agent function calling.
API Endpoint
Request:
POST /ag-ui/chat Content-Type: application/json Authorization: Bearer {token}Response: Server-Sent Events stream
Frontend Integration
CopilotKit Example
Custom TypeScript Client
Documentation
Comprehensive documentation provided:
Testing
The plugin has been verified to:
Test with curl:
Test with CopilotKit:
Use any CopilotKit example app and point it to the BotSharp
/ag-ui/chatendpoint.Benefits
References
Closes #[issue-number]
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/ag-ui-protocol/ag-ui/pulls/38/filescurl -L REDACTED(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.