VicroCode
Make Code Create Value
VicroCode is a lightweight online platform for publishing, running, sharing, and monetizing code projects. Launch HTML, Python, SQLite, AI agents, management tools, games, and more without server setup.
Please wait while VicroCode loads. You can also explore the AI programming guide
Loading...

AI MARKET GUIDE

Embedding a business form in an agent chat: who renders, who holds the data

The AG-UI vs MCP Apps debate hides the real work. Split the problem: a hosted HTML form plus a tool-callable SQLite endpoint, with the agent only resolving intent.

Someone on V2EX asked the question I keep running into: they want to drop an existing business form into an agent conversation. Cascading selects, data that loads on demand, history that prefills, and ideally the AI guessing sensible initial values from what the user just said. Their actual question was which protocol to bet on, AG-UI, MCP Apps, or rolling their own, and whether to have the agent emit a schema for the frontend to render or let MCP Apps ship a full UI.

I think that framing sends you down the wrong path first. Protocol choice is the volatile part. It depends on which host you're targeting, how that host embeds UI this quarter, and how the spec moves next quarter. If you start there, you end up coupling your form to a rendering surface you don't control, and you rebuild it when the surface changes.

Why split the problem before picking a protocol?

There are really two things tangled together in that request. One is *how pixels get drawn inside a specific chat client*, which is the protocol-specific half. The other is *where the form lives and where the data comes from*, which is plain web and database work. The second half is durable. It doesn't care whether the agent host speaks AG-UI, MCP Apps, or nothing at all, and you can build it today without guessing the winner.

So the shape I'd argue for: a real hosted form page, a data-and-schema endpoint backed by SQLite, and an agent whose only job is to understand intent and call a tool. The agent doesn't render the form and doesn't hold the data. It resolves what the user meant and hands off.

Which pieces can you actually build today?

**The form itself is an HTML page.** Cascading selects, conditional fields, validation, the prefill behavior, all of that is ordinary frontend logic. You can run HTML online and host it as a standalone page, which means it has a stable URL and works whether it's opened in an iframe, a new tab, or a webview. That page owns rendering. Nothing about it depends on a specific agent protocol, so when the protocol story shifts you keep the form.

**The data and schema come from a tool-callable endpoint.** This is where cascading selects and dynamic loading get solved honestly. When the user picks a region, the form asks the endpoint for the matching cities; it doesn't ship the whole tree up front. History prefill is the same call in reverse: given a record id, return the saved values. You can stand this up as a Python backend and expose it through API Endpoint Hosting, and the same endpoint is reachable as an in-platform tool call, so the agent and the form hit one source of truth instead of two drifting copies.

**The store is SQLite.** Option lists, the dependency rules between fields, and submitted records all fit a relational store cleanly. Cascading selects are a parent-child query; history prefill is a select by id. Having a SQLite editor on hand matters more than it sounds, because during a form build you spend real time poking at seed data, fixing a mislabeled option, and checking what a submission actually wrote. Being able to open the table and edit a row directly beats writing a throwaway script every time.

**The agent resolves intent and calls the tool.** This is the only part that's genuinely "AI," and it's narrow on purpose. The user says something like "renew the Shanghai contract from last March," the agent maps that to a tool call with the right record id and a few prefilled fields, and the form opens already populated. The autofill the original poster wanted lives here, as intent-to-parameters, and you can build that resolution logic with AI agent development against models already in the Model Center. Keep the agent out of rendering and out of persistence; the more it only *decides and calls*, the less there is to break.

Where does this approach stop working?

The protocol-specific rendering is the part I'd flag as outside what I'd promise here. If your requirement is specifically that the form draws *inside* a particular agent client through AG-UI's event stream or MCP Apps' embedded UI contract, that's a client-side integration against that spec and that host, and I'm not going to claim support for those rendering surfaces that I can't confirm. What's confirmed is the hosted HTML page, the SQLite-backed endpoint, the tool call, and the intent resolution. In practice the hosted page covers a lot of ground, because most hosts can open a URL or embed an iframe, and your form keeps working when they can't.

The trade-off is plain. You give up the tightest possible native-in-chat look, and in return the form, the data, and the logic are yours, testable on their own, and portable across whatever the agent host does next. If the protocol question resolves later, you bolt the thin rendering adapter onto a form that already works. If it doesn't resolve, you've lost nothing.

For a solo developer or a small team, that's the version worth shipping first. Build the durable half, keep the agent's job small, and don't let a moving spec own your form.

FAQ

Who should render the form inside an agent chat?

Decide who owns the data first. If the business owns it, the form should post to the business endpoint rather than live inside the transcript.

Do you need a new protocol?

Usually not. A plain HTML form posting to an existing endpoint covers most cases; protocols only pay off when several parties must interoperate.

What is the main risk?

Data residency and trust. Once a third party renders the form, it also sees what users type.

Further reading