A2UI Agent SDK は、モデル出力をそのまま JSON transport に縛らず、inference format ごとのプロンプト断片とコンパイラをカタログ JSON Schema から生成する。inference_format_factory で形式を指定すると、A2uiRequestProcessor が応答を検証済み A2UI メッセージに変換する。

python
from a2ui.processor import A2uiGenerator, CatalogConfig
from a2ui.inference_formats import ExpressFormatFactory

catalog = CatalogConfig.from_path("catalog.json")
generator = A2uiGenerator(
    [catalog],
    examples=few_shot_examples,
    inference_format_factory=ExpressFormatFactory(),
)

processor = generator.create_processor(renderer_capabilities)
system_prompt = f"{instructions}\n\n{processor.prompt_snippet}"
parts = processor.parse_response(model_reply)

Express は Python 風の 1 行 1 代入 DSL で、変数名が component ID、位置引数はカタログ schema のプロパティ順、$/title が data model、Event("accept") が server action を表す。Direct JSON から Express へ切り替えてもカタログとレンダラは据え置き。

Google の 51 タスク eval(gemini-3.5-flash)では、同種 UI を Express で書くと Direct JSON 比で生成トークンが約三分の一、レイテンシ改善の余地は最大約 3 倍。thinking off でも Express は Direct JSON と同等に eval を通過する。Python a2ui-agent-sdk 0.9.0、npm @a2ui/agent、Dart a2ui_agent 0.0.1-wip004 が Express を同梱。Direct JSON は chunk 単位ストリーム、Express はブログ執筆時点では完成応答からのコンパイルが TypeScript / Python の既定経路。

レイアウトが事前定義できる画面(設定、チェックアウトなど)向けに、TypeSafe の Jev のような System One モデルで grammar 上の選択肢だけ答え、コード側が createSurface / updateComponents を組み立てる controlled generation も紹介されている。Apparite(jev2ui)の小規模試行では component tree 表示が 92〜298 ms、画面完成が 0.8〜1.7 s。Agent SDK 本体には decision model 用 inference format は未同梱で、サンプル実装として位置づけ。

選択の目安:

  • 固定レイアウトが grammar で表せる → decision model(最速候補)
  • カタログ全体の expressivity が必要 → Express
  • 別 DSL → プロンプト生成器と A2UI への変換器を差し替え

#参考文献