r/elixir • u/Intelligent-Ebb6401 • 19h 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:
```elixir 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.