AGUI protocol on Bedrock: Stream agents via SSE

Blog 13 min read

AWS launched AG-UI protocol support for Bedrock AgentCore Runtime on March 13, 2026, enabling real-time agent streaming. This integration proves that decoupled agent logic requires a standardized event stream rather than custom API glue. The AG-UI protocol serves as the critical bridge between backend reasoning engines and flexible frontend rendering layers.

Amazon Bedrock AgentCore acts as a secure proxy: it handles authentication and session isolation while your container listens strictly on port 8080 and streams responses as SSE events, without rewriting core agent code. The FAST template ships pre-built patterns for Strands Agents and LangGraph, and CopilotKit extensions add human-in-the-loop interactions and shared canvases on top. Because the protocol is open, teams can swap frontend libraries like React or Vue without altering backend agent frameworks.

The Role of AG-UI in Decoupling Agent Logic from Frontend Rendering

AG-UI Protocol Definition: Event-Based Agent-to-User Standard

AG-UI establishes an open, event-based standard that separates agent logic from how interfaces render content. This Agent-User Interaction Protocol lets backends emit structured events for generative UI, shared state, and human-in-the-loop approvals instead of relying on static text streams. Abstraction of the communication layer allows developers to pair diverse agent frameworks like Strands Agents, LangGraph, and CrewAI with any frontend library such as React or Angular. Server-sent events form the backbone of this mechanism, translating framework-specific outputs into a unified contract. Support extends natively or via integration to at least three distinct agent frameworks: Strands Agents, LangGraph, and CrewAI.

Modular architecture emerges from this decoupling, permitting backend and frontend teams to iterate independently. Adopting this event-driven model shifts complexity away from custom API glue code toward rigorous event definition and validation. Teams gain the flexibility to swap LangGraph for CrewAI without rewriting the user interface, provided the agent adheres to the core protocol specification. Such separation ensures Amazon Bedrock AgentCore acts as a transparent proxy, handling authentication and scaling while the agent focuses on tool execution.

Deploying AG-UI on Amazon Bedrock AgentCore Runtime Port 8080

Containerized servers running the AG-UI protocol on Amazon Bedrock AgentCore Runtime must listen on port 8080 for all incoming HTTP and WebSocket traffic. This fixed configuration ensures the runtime correctly routes Server-Sent Events (SSE) to the /invocations path while maintaining health checks via /ping on the same interface. Deploying a container with the AG-UI protocol flag enabled turns the platform into a transparent proxy that automatically manages authentication using Signature Version 4 (SigV4) or OAuth 2.0 through Amazon Cognito. Developers no longer need to engineer custom middleware for session isolation or complex auto-scaling rules since the runtime handles these operational burdens natively. Select this deployment model over standard chat interfaces when an application demands persistent bidirectional state or human-in-the-loop approvals rather than simple request-response text streams. Engineers building with Strands Agents can use wrappers like ag-ui-strands to automatically encode these events, simplifying the integration of generative UI components. Frontend libraries like React remain decoupled from backend logic yet still receive real-time updates for shared canvases or inline charts without custom WebSocket servers.

AG-UI vs MCP and A2A Protocols in the Agent System

Specific design goals distinguish AG-UI as an event-based standard for Agent-to-User interaction, filling a gap alongside the Model Context Protocol (MCP) for tool connectivity and the Agent-to-Agent (A2A) protocol for inter-agent communication. MCP connects agents to external data sources while A2A enables multi-agent coordination, yet only AG-UI handles rendering generative UI components directly to end users. The AG-UI protocol contract specifies that a timestamp advancing on every ping prevents idle session timeouts, allowing sessions to persist until the MaxLifetime limit is reached.

Feature AG-UI Protocol MCP A2A Protocol
Primary Role Agent-to-User rendering Tool connectivity Inter-agent messaging
Data Type UI Events & State Tool Definitions Structured Agent Tasks
Target Frontend Libraries External APIs Other AI Agents

AG-UI serves as the transport mechanism for user interactions rather than a specification for the UI widgets themselves, keeping the protocol agnostic to specific rendering technologies. Architectural clarity ensures Amazon Bedrock AgentCore routes discrete traffic types through dedicated handlers, preventing misapplication of tool-oriented protocols for complex front-end tasks. Recognizing this boundary helps developers building interactive agents keep session management and state synchronization strong across the user interaction layer.

Architecture of Event Streaming and Shared State in AgentCore Runtime

Session Isolation and Proxy Mechanics in AgentCore Runtime

Amazon Bedrock AgentCore Runtime sits between the user and the agent container, acting as a transparent proxy that enforces session isolation before any request reaches application code. Deploying with the AG-UI protocol flag triggers automatic handling of Signature Version 4 [SigV4] or OAuth 2.0 through Amazon Cognito, removing the need for custom authentication middleware inside the container. The application exposes POST /invocations to receive AG-UI requests and GET /ping for health checks, binding strictly to port 8080. This design separates connection management from business logic, letting the runtime scale traffic independently while the agent focuses on execution.

Session state shifts from an application feature to an infrastructure concern. Centralizing these cross-cutting duties allows the full-stack AgentCore Solution Template (FAST) to process requests with integrated identity context via Amazon Cognito. Both Strands Agents and LangGraph patterns run under this unified security model without requiring framework-specific auth implementations.

Implementing Shared State with agui-strands-agent and agui-langgraph-agent

Wrapping framework-specific agents with StrandsAgent or LangGraphAGUIAgent enables bidirectional shared state persistence. The agui-strands-agent pattern uses the ag-ui-strands library to translate streaming events into AG-UI Server-Sent Events automatically. In contrast, the agui-langgraph-agent pattern employs LangGraphAGUIAgent from the copilotkit library to compile graphs fresh on every request. Both implementations attach AgentCore Memory per thread using a session-manager provider, ensuring conversation history survives scaling events. Code uses BedrockAgentCoreApp to read AgentCore Runtime headers like WorkloadAccessToken, Authorization, and Session-Id.

Frontend parsers consume these standardized events to render flexible interfaces without needing knowledge of the backend framework. This abstraction supports complex workflows, such as a shared todo canvas or a meeting scheduler that pauses execution for human input. The protocol defines a typed event stream over Server-Sent Events, guaranteeing consistent communication between the agent runtime and the frontend.

Memory remains opt-in; the provider returns None if MEMORY_ID is unset. This design prevents accidental state leakage between distinct user sessions in multi-tenant deployments. Validating header extraction logic is necessary to guarantee proper context isolation before production rollout.

Validating AG-UI Protocol Compliance for Timestamp Pings and Memory Providers

Operators must verify the container advances the timestamp on every ping to prevent premature session termination before the MaxLifetime limit expires. The protocol contract mandates this counter increment to signal active status, yet omitting it triggers idle timeouts regardless of backend processing state. This mechanism ensures long-running tasks do not fail due to transport-layer inactivity policies set in the runtime agreement. Relying solely on ping intervals ignores data persistence requirements for complex workflows.

Memory configuration stays optional, so unlike fixed session timers this model requires code-level checks for the memory provider existence.

Developers using the agui-langgraph-agent pattern must ensure the graph compilation respects these null states. When MEMORY_ID is unset, the agent operates without persistent conversation history, requiring explicit handling of stateless interactions during scaling events. Testing these edge cases under load confirms session continuity and proper memory attachment.

Strategic Advantages of the FAST Template for Multi-Framework Agent Development

Architectural Divergence: agui-strands-agent vs LangGraphAGUIAgent Initialization

Wrapping a Strands Agent happens through the StrandsAgent class inside the ag-ui-strands library to translate streaming events automatically. The agui-langgraph-agent takes a different path by using LangGraphAGUIAgent from the copilotkit library to compile a graph fresh per request. Both patterns scope MCP tools specifically to the caller, yet their initialization lifecycles diverge notably regarding object instantiation and event translation.

Dimension agui-strands-agent agui-langgraph-agent
Wrapper Class StrandsAgent LangGraphAGUIAgent
Library Source ag-ui-strands copilotkit
Execution Model Direct agent wrapping Compiled graph construction
Tool Scoping Fresh Gateway MCP per call Fresh MCP per call

The Strands approach relies on a direct wrapper that intercepts native streaming events without extra steps. LangGraph constructs a new execution graph for every invocation instead. This distinction means the LangGraph pattern incurs a compilation overhead absent in the direct wrapping model.

Cold-start latency suffers when graph compilation enters the equation compared to simple object wrapping. Strict type safety for complex multi-step workflows becomes available only through the compiled graph structure. Teams should select the pattern based on whether their priority is minimal initialization latency or rigorous workflow validation. Builders aiming for rapid iteration on standard chat interfaces may prefer the Strands wrapper. Those requiring complex state machines should adopt the LangGraph compiler despite the overhead, since Strands lacks the native cycle detection of compiled graphs and can loop indefinitely on unbounded reasoning tasks without external guards. AI Agents News recommends validating both initialization paths against your specific latency budgets before production deployment.

Deploying Generative UI and Shared State with CopilotKit on AgentCore

Custom components like pieChart render inline when agents trigger them via AG-UI tool calls using the CopilotKit React library. This mechanism shifts control from static templates to flexible, declarative descriptions where the agent queries data and triggers specific UI renders through tool call events. Bidirectional synchronization maintains a shared todo canvas. User edits update the system prompt, allowing the agent to call manage_todos and refresh the view via state snapshots.

Feature Prebuilt Components Declarative AG-UI
Control Locus Frontend Code Agent Logic
Flexibility Fixed Schema Flexible Structure
Integration Static Props Event-Driven

Framework agnosticism across Strands, LangGraph, and CrewAI works without rewriting the frontend parser. Managing component registration lifecycles within the React host application adds complexity though. Builders must ensure the frontend strictly validates incoming tool call names against a whitelist to prevent unauthorized component rendering. Visual evolution decouples from backend logic, permitting independent iteration on charting libraries or canvas widgets. AI Agents News readers should note that while this enables rich human-in-the-loop approvals, it requires rigorous testing of state synchronization to avoid race conditions during rapid user inputs.

Deploying Secure Generative UI Agents with Cognito and CDK

FAST Application Deployment Architecture via CopilotKit and AgentCore

Cloning the FAST Samples repository starts the chain reaction that builds core infrastructure through a single shell script execution. This operation spawns an Amazon Cognito user pool, an Amazon ECR repository, and the required AgentCore Runtime, Gateway, and Memory resources. The process simultaneously deploys the CopilotKit Runtime Lambda backed by Amazon API Gateway alongside AWS Amplify hosting for the interface.

  1. Configure the config.yaml file with your specific AWS account details.
  2. Run ./deploy-strands.sh or ./deploy-langgraph.sh to initiate the stack creation.
  3. Verify the installation by requesting the agent render a pie chart or update a todo list.

Manual configuration of SSE endpoints and auth middleware becomes unnecessary with this architecture, removing a common source of production friction. The system wraps agent logic to handle event encoding for server-side transmission automatically, sidestepping custom middleware development. Shared state and human-in-the-loop interactions function immediately, meeting enterprise requirements without extra plumbing.

Convenience here creates a rigid dependency on the provided CDK templates. Changing the underlying network topology demands a fork-and-modify workflow instead of simple parameter overrides. Operators gain rapid iteration speed yet sacrifice fine-grained control over VPC peering or custom subnet placement during the initial deployment phase.

Executing FAST Deployment Scripts and Verifying Generative UI Endpoints

Run ./deploy-strands.sh or ./deploy-langgraph.sh from the copilotkit-generative-ui directory as described above, then move on to verification. Those scripts remove the need for manual SSE endpoint and auth middleware setup, tasks typically required when native support is absent. Validation requires testing specific generative UI capabilities once the stack status reports CREATE_COMPLETE, moving beyond simple text responses. Issue a prompt requesting a pie chart render or ask the agent to add tasks to the todo canvas. These actions verify that the frontend parses AG-UI events correctly and that shared state synchronization functions bidirectionally. The AgentCore Runtime container must expose port 8080 for these health checks and invocations to succeed, representing a hard constraint. If the agent fails to render the component, check Amazon Cognito token exchange logs before assuming a framework error. Infrastructure errors often manifest as silent failures in the event stream rather than explicit crash logs because deployment logic remains separate from agent code.

Infrastructure Cleanup Protocol Using CDK Destroy Commands

Tearing down deployed stacks immediately after testing prevents ongoing charges. Leaving resources active incurs costs for Amazon ECR storage and AgentCore Runtime compute capacity even when idle. The cleanup process requires executing specific AWS Cloud Development Kit commands tailored to your deployment target.

  1. Navigate to the infra-cdk directory and run npx cdk destroy --all to remove core FAST infrastructure components.
  2. For CopilotKit samples, execute npx cdk destroy --all within the specific sample project directory.
  3. Manually delete any lingering Amazon ECR repositories if the automated stack removal fails to clear container images.

This sequence ensures the Amazon Cognito user pool and AWS Amplify hosting environment are fully decommissioned. Operators must verify that CopilotKit Runtime Lambda functions no longer appear in the console post-execution. Failure to manually purge Amazon ECR assets often leaves small but persistent billing items on the account. This final step completes the lifecycle management for temporary agentic environments.

About

Diego Alvarez serves as a Developer Advocate at AI Agents News, where he specializes in hands-on build guides and technical comparisons for autonomous systems. His daily work involves constructing end-to-end agents using frameworks like LangGraph and CrewAI, giving him direct, practical insight into the complexities of decoupling agent backends from frontend interfaces. This specific experience makes him uniquely qualified to explain the AG-UI protocol, as he routinely encounters the exact friction points regarding shared state and human-in-the-loop interactions that the protocol resolves. At AI Agents News, a hub dedicated to helping engineers evaluate and build with agentic technologies, Diego focuses on translating abstract standards into runnable code. By connecting the theoretical benefits of Amazon Bedrock AgentCore with real-world implementation challenges, he ensures readers understand not just how AG-UI functions, but why it is critical for building reliable, production-ready generative UI applications.

Conclusion

AG-UI turns the boundary between agent and interface into a typed event stream: the backend emits events, the frontend renders them, and neither side needs to know how the other is built. On Amazon Bedrock AgentCore Runtime that boundary is enforced by infrastructure rather than by glue code, provided the container listens on port 8080 and advances the timestamp on every ping. The FAST template proves the point by running the same contract over Strands Agents and LangGraph: change the framework, keep the frontend.

Silent event stream failures usually sit on that boundary rather than in agent logic. When a generative UI component fails to render, check Amazon Cognito token exchange and bidirectional state synchronization before rewriting the agent. Once validation ends, run npx cdk destroy --all and confirm the Amazon Cognito user pools and CopilotKit Runtime Lambda functions disappear from the console, because idle AgentCore Runtime and Amazon ECR resources keep accruing charges.

Frequently Asked Questions

Servers must listen strictly on port 8080 for all HTTP and WebSocket traffic. This fixed configuration ensures the runtime correctly routes Server-Sent Events to the invocations path while maintaining health checks.

A timestamp advancing on every ping prevents idle session timeouts effectively. This mechanism allows sessions to persist continuously until the MaxLifetime limit is reached without unexpected disconnections.

The protocol supports at least three distinct agent frameworks including Strands Agents, LangGraph, and CrewAI. This flexibility lets teams swap backend logic without rewriting the user interface code.

AG-UI handles rendering generative UI components directly to end users specifically. Unlike MCP for tools or A2A for agents, it manages flexible events like shared state and human approvals.

The platform manages authentication using Signature Version 4 or OAuth 2.0 through Amazon Cognito. Developers no longer need to engineer custom middleware for session isolation or complex scaling rules.

References