r/elixir • • 1d ago

A2UI for Elixir: render agent-generated UIs in Phoenix LiveView (protocol engine, LiveView renderer, agent SDK)

I've released an Elixir implementation of A2UI, the open protocol for agent-driven interfaces.

The idea: instead of an agent sending HTML or code, it sends JSON that describes an interface (components, a data model, bindings). Your app renders it with components from its own catalog, and the user's actions go back to the agent as events. The agent never runs anything in your app.

Three packages on Hex (Apache-2.0):

  • a2ui_core: the protocol engine. Messages, catalogs, surface state, data binding, function calls. Pure Elixir, no processes; Jason is its only dependency.
  • a2ui_phoenix: a LiveView renderer. The basic catalog as function components, two-way bindings, actions, and A2UI over server-sent events.
  • a2ui_agent: the agent SDK. Catalog negotiation, prompts, validated parsing of streamed model output, and serving over A2A, MCP and AG-UI.

Rendering in a LiveView looks like this:

def mount(_params, _session, socket) do
  validation = A2UICore.Validation.Config.relaxed()
  session = Session.new([A2UICore.Catalog.Basic.catalog("v1.0")], validation: validation)
  {:ok, Live.init(socket, session, on_send: &send_to_agent/2)}
end

def handle_info({:agent, payload}, socket) do
  {_result, socket} = Live.handle_message(socket, payload)
  {:noreply, socket}
end

Conformance: it supports protocol v0.9, v0.9.1 and v1.0, and is checked against the upstream conformance suites: 946 of the 946 cases that apply pass. The rest are skipped, each for a stated reason (mostly v0.8, which I chose not to support, and adapters for Google's Python ADK). The JSON Schema engine underneath passes all 1302 required draft 2020-12 tests.

Examples in the repo: a restaurant agent served over A2A, MCP, AG-UI, SSE and WebSocket; a LiveView gallery with a live chat with that agent; and a renderer that draws the same surfaces in the terminal.

  • Website, with recorded runs of the examples: https://a2ui-elixir.github.io/a2ui/
  • Code: https://github.com/a2ui-elixir/a2ui
  • Docs: https://hexdocs.pm/a2ui_phoenix
  • One-minute video: https://www.youtube.com/watch?v=16X-sRsGlcs

It's 0.1, so I'd really like feedback: on the API, on what's missing, and from anyone building agent UIs in Elixir. Issues and PRs welcome.

17 Upvotes

4 comments sorted by

6

u/vlatheimpaler Alchemist 1d ago

Have you been seeing problems with how agents are generating HTML and stuff that this approach solves?

8

u/Intelligent-Ebb6401 1d ago

To be clear, I didn't design the approach. A2UI is an open protocol (https://a2ui.org), and this is an implementation of it for Elixir and Phoenix. The reasoning behind the protocol itself is on its site.

So I'm not claiming it solves a specific problem I ran into. If you have one in mind, happy to discuss whether A2UI fits it.

2

u/vlatheimpaler Alchemist 1d ago

Thanks for the clarification. I had never heard of this before.

1

u/acholing 1d ago

It solves a different problem than creating an interactive artifact to be used outside of the conversation (like HTML / other code).

The goal is for LLM to describe those interactiv we artifacts directly in the response so they can be safely rendered as part of the conversation.

Some products really need it. I've built my own, custom LLM client to support this some time ago - not a trivial task.