examples/agent/a2ui_agent/README.md
A2UI (Agent-to-Agent UI) is a protocol for agents to send streaming, interactive user interfaces to clients. It enables LLMs to generate platform-agnostic, declarative UI definitions that clients can render progressively using native widget sets.
In this example, we demonstrate how to integrate A2UI into a ReAct agent in AgentScope. This implementation is based on the official A2UI agent samples, adapted to use AgentScope's agent framework.
Specifically, we have:
Reimplemented the agent with AgentScope: The agent part of the official A2UI samples has
been reimplemented using AgentScope's ReActAgent, providing a more familiar and integrated
development experience for AgentScope users.
Progressive schema and template exposure via skills: To help the agent learn and generate
A2UI-compliant interfaces, we use AgentScope's skill system to progressively expose the A2UI
schema and UI templates. The agent can dynamically load these resources through the
A2UI_response_generator skill, enabling it to understand component definitions and learn from
example UI structures.
The following directories in this example contain content sourced from the Google A2UI repository:
samples/client/: A2UI client sample applicationsNPM Package Status: As of now, the A2UI client libraries (@a2ui/lit and @a2ui/angular) are not yet published to NPM. According to the official A2UI client setup guide: "The Lit client library is not yet published to NPM. Check back in the coming days."
Therefore, these dependencies are currently included in this example repository using local file paths (e.g., "@a2ui/lit": "file:../../../../renderers/lit" in package.json files). This mirrors the approach used in the official A2UI repository, where the renderers and samples also use local file paths to reference each other. Additionally, the copy-spec task in renderers/lit/package.json copies files from the local specification/ directory during the build process.
Future Plans: Once those libraries are published to NPM, we plan to gradually migrate to using the official NPM packages and remove these locally included directories.
Download the a2ui and agentscope package to the same directory
git clone https://github.com/google/A2UI.git
git clone -b main https://github.com/agentscope-ai/agentscope.git
# copy the renders and specification directory to AgentScope/examples/agent/a2ui_agent
cp -r A2UI/renderers AgentScope/examples/agent/a2ui_agent
cp -r A2UI/specification AgentScope/examples/agent/a2ui_agent
Then, navigate to the client directory and run the restaurant finder demo:
cd AgentScope/examples/agent/a2ui_agent/samples/client/lit
npm run demo:restaurant
This command will:
Note:
- The example is built with DashScope chat model. Make sure to set your
DASHSCOPE_API_KEYenvironment variable before running the demo.- If you are using Qwen series models, we recommend using
qwen3-maxfor better performance in generating A2UI-compliant JSON responses.- Generating UI JSON responses may take some time, typically 1-2 minutes, as the agent needs to process the schema, examples, and generate complex UI structures.
- The demo uses the standard A2UI catalog. Custom catalog and inline catalog support are under development.
AgentScope's main focus going forward will be on improving How Agents Work with A2UI. The workflow we're working towards is:
User Input → Agent Logic → LLM → A2UI JSON
Our optimization efforts will focus on:
Agent Logic: Improving how agents process inputs and orchestrate the generation of A2UI JSON messages
Handle user interactions from the client: Enabling agents to properly process and respond to user interactions from the client (such as button clicks, form submissions), treating them as new user input to create a continuous interactive loop
Current approach: The skill-based method we've implemented in this example is our first step towards this goal. By using AgentScope's skill system to progressively expose the A2UI schema and templates, agents can learn to generate compliant UI structures. Future improvements will focus on streamlining this process and making it more intuitive for developers to build A2UI-capable agents.
Next steps for Agent Logic improvement
Agent skills improvements:
Context management in Memory for A2UI long context:
Keep up with A2UI protocol updates: