This solution has been AI generated
This happens because the LLM’s form response is producing malformed A2UI JSON (bad escaping and/or missing sections). Forms are more complex than dashboards and require a strict sequence and proper string escaping, so the middleware fails with “Bad escaped character.” Updating your system instructions with a concrete form example typically resolves it.
Why this happens
- JSON escaping issues: nested strings in
a2ui_json (quotes/newlines) aren’t escaped correctly, causing the parse error.
- Instruction gaps: the model isn’t told the exact structure for A2UI forms (bindings and initialization).
- Complex nesting: forms must include
surfaceUpdate, dataModelUpdate, and beginRendering; if any are malformed/missing, parsing fails.
Fix: strengthen your A2UI system prompt
Add a concrete, one-shot example for forms and explicit rules:
Rules for Forms
- Send
surfaceUpdate, dataModelUpdate, and beginRendering in ONE tool call.
- Bind inputs with
"text": { "path": "/form/fieldName" }.
- Always include
dataModelUpdate to initialize paths.
[
{
"surfaceUpdate": {
"surfaceId": "user-info-form",
"components": [
{ "id": "root", "component": { "Card": { "child": "form-col" } } },
{ "id": "form-col", "component": { "Column": { "children": { "explicitList": ["name-field", "email-field", "age-field", "submit-btn"] } } } },
{ "id": "name-field", "component": { "TextField": { "label": { "literalString": "Name" }, "text": { "path": "/form/name" } } } },
{ "id": "email-field", "component": { "TextField": { "label": { "literalString": "Email" }, "text": { "path": "/form/email" } } } },
{ "id": "age-field", "component": { "TextField": { "label": { "literalString": "Age" }, "text": { "path": "/form/age" } } } },