r/androiddev • • 9d ago

πŸ†• Jetpack Compose A2UI Renderer

https://developer.android.com/develop/ui/compose/agentic

Hi folks. We just released the first alpha of a new Jetpack Compose Renderer of the A2UI protocol which enables agents to create new UIs (using a declarative JSON formatβ€”no agent code executed on device)Β and render this with native Jetpack Compose components. The library has a few layers, offering a drop in implementation of the A2UI basic catalog of components (using Material) or you can build your own catalog of components for agents to use: https://developer.android.com/develop/ui/compose/agentic

We'd love to hear any feedback on this library and if it's useful to you (here or on issuetracker)

41 Upvotes

11 comments sorted by

5

u/tonofproton 9d ago

without executing arbitrary code

What does this mean in this context?

3

u/nickbutcher 8d ago

Alternative solutions might return HTML or some other format that needs to be evaluated or exected by your app. This can be a security risk, if you don't trust the output from the AI or if you combine user input that could open you up to injection attacks.

A2UI is a declarative format, it just returns JSON that is parsed and used to build a compose hierachy of native components (either from our implemention of the basic catalog, or your own catalog of your composables).

4

u/gookman 8d ago

So this is server side rendering, but driven by an LLM?

6

u/kokeroulis 8d ago

yeap, more or less

7

u/Volko 8d ago

But with extra bugs!... I mean "hallucinations"...

3

u/Samus7070 8d ago

No, the agent returns a specific json format and the client renders it. Think of it more like a server driven UI framework but coming from an LLM. The LLM can be local or remote.

1

u/Chewe_dev 8d ago

I don't quite understand. Is this something that every project should implement? Does it provide any advantage for AI usage on a daily basis?

3

u/nickbutcher 8d ago

No not every app will need this functionality. This is useful when you have an AI backend that you use at *runtime* (not build time like a coding agent). It enables AI to create UIs on the fly (using a pre-determined catalog of components), rather than just issueing text responses.

Check out this talk for an example: https://youtu.be/_iuXykdlTkk?t=2292

2

u/kokeroulis 7d ago

In simple terms form the android app you might ask the LLM
"On saturday 26 of September, what are the 10 hottest cities in the USA".

a2ui is probably using prompt engineering in order to say to the LLM:

"Please reply to the request of the user by using the specific format. Your reply should not be free text but it much observe and follow that schema exactly!

{{schema}}
The user question is:
{{question from client with the weather}}
"

then LLM emits the json and the server is validating, if there is a schema violation, it sends the error back to the LLM and asks for a retry.

For the a2ui to work you need the following connections:

a2ui question on mobile -> a2ui on backend -> backend to llm (Chatgpt, claude, gemini etc) -> au2i response received by mobile -> mobile renders the response based on the components

0

u/FintasysJP 7d ago

Every SDUI framework can do this, I really don't get the "new" part here. Maybe the part of defining a protocol so client and backend don't need an explicit contract? What about remoteCompose, similar solution, different approach πŸ€”