feat: add AG-UI (AGUI) as fourth first-class protocol mode#858
Open
aidandaly24 wants to merge 11 commits intoaws:mainfrom
Open
feat: add AG-UI (AGUI) as fourth first-class protocol mode#858aidandaly24 wants to merge 11 commits intoaws:mainfrom
aidandaly24 wants to merge 11 commits intoaws:mainfrom
Conversation
Contributor
Package TarballHow to installnpm install https://github.com/aws/agentcore-cli/releases/download/pr-858-tarball/aws-agentcore-0.8.1.tgz |
Add AGUI protocol support across the full CLI stack: - Schema: Add 'AGUI' to ProtocolModeSchema, PROTOCOL_FRAMEWORK_MATRIX (Strands, LangChain_LangGraph, GoogleADK), and RESERVED_PROJECT_NAMES - Types: New agui-types.ts with 27 event type enum, typed interfaces, parseAguiEvent parser, and buildAguiRunInput helper - Templates: Python AGUI agent templates for Strands (ag-ui-strands), LangGraph (ag-ui-langgraph), and GoogleADK (ag-ui-adk) frameworks - Invoke: invokeAguiRuntime with dual-stream architecture (typed events for TUI, text-only for CLI), local dev invokeAguiStreaming with RunAgentInput body, protocol dispatch in invokeForProtocol - TUI: Rich AGUI event rendering with MessagePart type (text, tool_call, reasoning, error) in InvokeScreen, AGUI placeholder text in DevScreen - Validation: Updated error messages and help text to include AGUI - Tests: 24 unit tests for parseAguiEvent/buildAguiRunInput, snapshot updates for new template files
HIGH fixes: - Add sessionId to AguiInvokeOptions, pass as runtimeSessionId (H-1) - Throw early for bearerToken on AGUI (not yet supported) (H-2) - Add bedrock-agentcore dep to all 3 template pyproject.toml files (H-4/5/6) - Fix LangGraph /ping to return "healthy" not "ok" (H-7) - Match TOOL_CALL_RESULT to tool_call parts by toolCallId, not position (H-12) - Add complete enum coverage to agui-types test (H-15) MEDIUM fixes: - Fix langchain version pin from 1.2.0 (nonexistent) to 0.3.0 (M-11) - Remove invalid allow_credentials=True with wildcard CORS (M-12) - Replace in-place parts mutation with immutable updates for React safety (M-5) - Surface readLoop errors in consumer generators instead of swallowing (M-1) - Disable retry once streaming starts to prevent duplicate output (M-3) - Handle TEXT_MESSAGE_CHUNK events alongside TEXT_MESSAGE_CONTENT (M-2) - Update gemini model from 2.0-flash to 2.5-flash in GoogleADK (M-8) - Add missing event type exports to barrel index.ts (M-18) LOW fixes: - Move AGUI imports to top-level in action.ts (L-1) - Gate OTEL_SDK_DISABLED on LOCAL_DEV env var in Strands template (L-9) - Add explanatory comment for LANGGRAPH_FAST_API env var (L-10)
- Add AGUI option to PROTOCOL_OPTIONS in generate/types.ts so users
can select AGUI from the interactive create/add wizards
- Add AGUI case to useDevServer.ts sendMessage dispatch so local dev
TUI sends correct RunAgentInput body via invokeAguiStreaming
- Add AGUI case to dev/command.tsx non-interactive dispatch so
agentcore dev "prompt" uses invokeForProtocol('AGUI')
load_model() returns None (it only sets GOOGLE_API_KEY env var as a side effect). Passing model=load_model() to Agent() results in model=None, causing the agent to either crash or use a default model. Fix: call load_model() standalone for the side effect, then pass the model ID string directly to Agent().
- AddScreen description: 'HTTP, MCP, A2A' → includes AGUI - create --protocol help text: includes AGUI - JSDoc comments in agent/types.ts, templates/types.ts, agent-env.ts - codezip-dev-server comment: 'MCP/A2A' → 'MCP/A2A/AGUI' - agent-env.test.ts: add AGUI to protocol acceptance test
- Add InvokeLogger to AGUI CLI invoke block (action.ts) for prompt/response logging and log file creation — parity with HTTP invoke path - Track RUN_ERROR events in textStream and return success: false when agent errors are detected - Pass sessionId and logger to invokeAguiRuntime options - Improve AGUI protocol picker description from circular 'AG-UI agent-to-user interaction protocol' to actionable 'Stream rich agent events to frontends (AG-UI)'
Bugs found by deploying all 3 AGUI frameworks to AWS and invoking: - Bump ag-ui-strands to >= 0.1.4 (0.1.3 crashes on strands >= 1.19.0 due to accessing removed private attr agent.state._state) - Remove parallel_tool_calls=False from LangGraph template (Bedrock rejects this OpenAI-specific parameter with ValidationException) - Remove aws-opentelemetry-distro from GoogleADK template (conflicts with google-adk >= 1.16.0 OpenTelemetry dependencies — agents using this template should set instrumentation.enableOtel: false)
When creating an AGUI project, users can now opt to include a CopilotKit frontend. A new "Frontend" TUI wizard step (AGUI only) offers 4 layout options: Sidebar, Popup, Chat, or No frontend. Template files (10) scaffold a Next.js + CopilotKit app in frontend/ that connects to the AGUI agent via CopilotRuntime proxy. CLI changes: - renderFrontendTemplate() function (EvaluatorRenderer pattern) - FrontendLayout type + frontendLayout on AgentRenderConfig - --frontend flag on agentcore create command - Frontend step in TUI wizard (before Advanced, AGUI only) - schema-mapper maps frontend config to frontendLayout
…flict
Handlebars interprets `={{` in JSX (e.g., `labels={{ title: "..." }}`)
as template syntax, causing parse errors during template rendering.
Fix: extract labels and suggestions as const variables before JSX,
using single-brace `{labels}` which Handlebars ignores.
3d2587b to
aa64583
Compare
avi-alpert
reviewed
Apr 15, 2026
|
|
||
| # Enable LangGraph FastAPI mode (must be set before langgraph imports) | ||
| os.environ["LANGGRAPH_FAST_API"] = "true" | ||
|
|
Contributor
There was a problem hiding this comment.
im thinking we will also want to add instrumentation like we do for the other langchain templates
avi-alpert
reviewed
Apr 16, 2026
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| uvicorn.run(app, host="0.0.0.0", port=8080) |
Contributor
There was a problem hiding this comment.
Suggested change
| uvicorn.run(app, host="0.0.0.0", port=8080) | |
| uvicorn.run(app, host="0.0.0.0", port=int(os.environ.get("PORT", "8080"))) |
for local testing it would be nice if we could optionally specify a different port through an env var. (If you end up making this change please apply it to all the agui templates)
The AGUI LangGraph template had a single-node graph (chat → END) with
no tool execution loop. When the model called add_numbers, the graph
exited without executing the tool or generating a text response,
producing "(no content in AGUI response)" in agentcore dev.
Template fix:
- Add ToolNode(tools=backend_tools) as a "tools" node
- Replace set_finish_point("chat") with tools_condition conditional edge
- Add edge from "tools" back to "chat" for the ReAct loop
- Separate backend_tools list from frontend tools (state["tools"])
This matches the standard LangGraph ReAct pattern (agent → tools →
agent → ... → END) and how the HTTP/A2A templates use create_react_agent.
Dev invoke fix:
- invoke-agui.ts now tracks TOOL_CALL_START/ARGS/END/RESULT events
- When no text is produced but tool calls were seen, surfaces them
as [Tool: name(args)] instead of generic "(no content)" message
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.
Description
Adds AG-UI (AGUI) as a fourth protocol mode in the AgentCore CLI alongside HTTP, MCP, and A2A. AGUI is an open, event-based protocol for agent-to-user interaction that enables rich streaming of structured events (text, tool calls, reasoning, state) from agents to frontends.
What's included:
Schema & Types
'AGUI'added toProtocolModeSchemaandPROTOCOL_FRAMEWORK_MATRIX(Strands, LangGraph, GoogleADK)agui-types.ts)parseAguiEvent()parser andbuildAguiRunInput()helperPython Agent Templates (3 frameworks)
src/assets/python/agui/strands/— usesag-ui-strands/StrandsAgent/create_strands_appsrc/assets/python/agui/langchain_langgraph/— usesag-ui-langgraph/LangGraphAgentsrc/assets/python/agui/googleadk/— usesag-ui-adk/ADKAgent/AGUIToolsetInvoke Layer
invokeAguiRuntime()with dual-stream architecture: typedstream(AG-UI events) for rich TUI +textStream(plain text) for CLIinvokeAguiStreaming()for local dev with properRunAgentInputbody constructioninvokeForProtocol(),handleInvoke(), and dev commandInvokeLoggerintegration for AGUI CLI pathTUI
MessagePart[]model (tool calls, reasoning, errors)Cross-codebase updates
agent-env.test.tsprotocol acceptance test includes AGUIcodezip-dev-server.tscomment updated for AGUIimport/types.tsandyaml-parser.tshardcoded unions updatedRelated Issue
Closes #796
Documentation PR
Type of Change
Testing
How have you tested the change?
npm run test:unitandnpm run test:integnpm run typechecknpm run lintsrc/assets/, I rannpm run test:update-snapshotsand committed the updated snapshotsDeployment Testing
All 3 AGUI framework configurations were deployed to AWS and invoked end-to-end:
Review Rounds
4 rounds of review (20 total reviewer agents) covering:
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.