Skip to content

feat(agent-sdk): add two-stage layout planner, synthesizer, and v1.0 decision format - #4155

Closed
gspencergoog wants to merge 6 commits into
feat/decision-core-backendsfrom
feat/decision-planner-format
Closed

gspencergoog wants to merge 6 commits into
feat/decision-core-backendsfrom
feat/decision-planner-format

Conversation

@gspencergoog

@gspencergoog gspencergoog commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds LayoutPlanner, PatternExpander, DecisionSynthesizer, LayoutLinter, and the DecisionFormat (a2ui-decision), DecisionParser, and DecisionRenderTool entry points under a2ui.inference_formats.experimental.decision in a2ui-agent-sdk, along with the architecture proposal in docs/proposals/decision_inference_format.md. Also removes all experimental format re-exports (decision, Atom*, and Elemental*) from the top-level a2ui.inference_formats barrel so importing the barrel never loads experimental modules.

Reviewer Focus

  • python/a2ui_agent/src/a2ui/inference_formats/__init__.py and .github/workflows/python_ci.yml: check that a2ui.inference_formats exports only stable formats (direct_json, express, and _shared helpers), and that the isolated CI check asserts no a2ui.inference_formats.experimental* or httpx modules load on barrel import.
  • docs/proposals/decision_inference_format.md: review the end-to-end architecture, block contract, two-stage question batching, three-level surface lifecycle, fallback hierarchy, and held-out benchmark scorecard.
  • python/a2ui_agent/src/a2ui/inference_formats/experimental/decision/decision_block.py and prompt_generator.py: check that the block contract (surfaceId, intent, payload, actions, mutablePaths, exclude, labels, region, replace, layout, title, summary, fallbackDsl) matches prompt rules.
  • python/a2ui_agent/src/a2ui/inference_formats/experimental/decision/layout_planner.py and patterns.py: inspect Stage 1 and Stage 2 batching, no_fit abstention routing, fit_score diagnostic threshold, exclude pointer filtering, labels overrides, event.name == action.id preservation, and $actionContext bindings. Two planner rules deserve a close look: a collection bound to a grouped section array (menuSections[i].items) expands into one section heading plus one collection per section, reusing the single collection gate and anatomy answers; and leading: icon or picture-based layouts degrade to none or rows when the bound items have no icon or picture field, so no Image is emitted without a url.
  • python/a2ui_agent/src/a2ui/inference_formats/experimental/decision/patterns.py (_eval_format_directive): check that $format resolves to formatCurrency, formatNumber, or formatString only when the owning catalog declares that function, and falls back to a plain binding otherwise, so recipes stay catalog-agnostic.
  • python/a2ui_agent/src/a2ui/inference_formats/experimental/decision/parser.py and synthesizer.py: check RendererState operations (create, root update, block region replacement, PlanCache updateDataModel-only fast path, and replace: true deleteSurface + createSurface) and the fallback chain (fallbackDsl, host callback, minimal facts surface, explicit error).
  • python/a2ui_agent/hatch_build.py and pyproject.toml: check how catalogs/decision/v1/*.json, catalogs/basic/v1/patterns.json, and calibration_profiles.json are bundled into a2ui/inference_formats/experimental/decision/assets/ for sdist and wheel builds.

Changes

  • Add archetypes.py, layout_planner.py, patterns.py, layout_lint.py, and synthesizer.py to compile JSON payloads, ActionSpec maps, and labels overrides into linted A2UI v1.0 messages.
  • Support PlanCache data-only updates (plan_cache_hit=True), block-level region replacement (updateComponents + updateDataModel without rewriting the page root), and no_fit / fit_score abstention routing.
  • Expand grouped section arrays into alternating heading (prose) and collection blocks with distinct id_prefix values, and propagate SlotBinding.format_hints so $format directives in a catalog's patterns.json render currency, number, and string formatting through the catalog's declared functions.
  • Add decision_block.py, prompt_generator.py, parser.py, format.py, and tool.py implementing DecisionFormat (chat mode) and DecisionRenderTool (tool mode) on A2UI v1.0. DecisionFormat, DecisionParser, DecisionSynthesizer, and DecisionRenderTool are decorated with @experimental (a2ui.utils._experimental), matching AtomFormat and ElementalFormat.
  • Remove experimental format re-exports (AtomFormat, AtomFormatFactory, AtomParser, ElementalFormat, ElementalFormatFactory, ElementalParser, and all decision symbols) from a2ui.inference_formats/__init__.py, update eval/a2ui_eval/runner.py to import AtomFormat and ElementalFormat from their experimental packages, and tighten .github/workflows/python_ci.yml to assert barrel isolation.
  • Add docs/proposals/decision_inference_format.md documenting the design, data flows, custom catalog integration, [decision] extra, and evaluation results.
  • Add hatch_build.py for wheel asset bundling, and update python/a2ui_agent/CHANGELOG.md (under ## Unreleased, including the breaking-change note for Atom and Elemental barrel removal), python/a2ui_agent/README.md, and inference_formats/README.md.
  • Add unit and end-to-end suites covering archetype loading, planning, pattern expansion, grouped collections, $format evaluation, multi-turn RendererState updates, PlanCache hits, region updates, action round-trips, custom catalogs, and wheel packaging.

Impact & Risks

  • Breaking change: AtomFormat, AtomFormatFactory, AtomParser, ElementalFormat, ElementalFormatFactory, and ElementalParser are no longer exported from a2ui.inference_formats. Callers must import them from a2ui.inference_formats.experimental.atom and a2ui.inference_formats.experimental.elemental directly.
  • Decision symbols are importable only from a2ui.inference_formats.experimental.decision (not the top-level barrel). Instantiating DecisionFormat, DecisionParser, DecisionSynthesizer, or DecisionRenderTool emits an [EXPERIMENTAL] UserWarning; set A2UI_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS=1 to silence it.
  • Multi-turn surface updates and PlanCache data-only hits rely on callers retaining a conversation-scoped RendererState; stateless callers continue to receive createSurface messages.

Testing

  • Run uv run pytest python/a2ui_agent/tests eval/tests -q to execute all decision, agent SDK, and eval suites.
  • Run uv build --package a2ui-agent-sdk and check that built wheels include all bundled JSON assets and list httpx only under extra == 'decision'.
  • Run uv run --all-packages mypy . and uv run pyink --check python/a2ui_agent eval.

Benchmark Results

Frozen scorecard from eval/bin/decision_scorecard.py (reported in docs/proposals/decision_inference_format.md), with per-model temperatures from calibration_profiles.json:

Split Backend Family Archetype Forced-Fit (none) Slot Bind Action Acc P50 / P95 Gate
tuning (16) jev/jev-1.14.0 (T = 1.0) 100.0% 100.0% 0.0% 100.0% 100.0% 90.2 / 138.8 ms pass
tuning (16) gemini/gemini-decision-1 (T = 0.25) 100.0% 93.8% 0.0% 100.0% 100.0% 239.2 / 402.7 ms pass
heldout (111) jev/jev-1.14.0 (T = 1.0) 100.0% 100.0% 3.1% (1/32) 100.0% 100.0% 86.6 / 114.2 ms pass
heldout (111) gemini/gemini-decision-1 (T = 0.25) 97.5% 94.9% 12.5% (4/32) 92.4% 96.8% 210.0 / 358.4 ms fail (forced-fit > 5%)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the experimental 'decision' inference format for protocol v1.0, which separates data from interface design by using a decision model to select layouts from catalog patterns. It adds several new modules, comprehensive documentation, and tests, while also updating the Hatch build configuration to bundle catalog assets. The review feedback suggests two key improvements: using setdefault in hatch_build.py to safely access build_data["force_include"] and avoid a potential KeyError, and optimizing the recursive _stamp_function_calls function in synthesizer.py to skip primitive values and reduce overhead.

Comment thread python/a2ui_agent/hatch_build.py Resolved
@gspencergoog
gspencergoog force-pushed the feat/decision-planner-format branch from 6858249 to 3a4e608 Compare November 13, 2026 22:50
@gspencergoog
gspencergoog marked this pull request as ready for review November 16, 2026 21:59
@gspencergoog
gspencergoog added this pull request to stack #4287 November 18, 2026 17:45
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

🧹 Docs Site Preview Removed

The preview for PR #4155 has been cleaned up because the pull request is closed.

github-actions Bot added a commit that referenced this pull request Nov 18, 2026
gspencergoog added a commit that referenced this pull request Nov 18, 2026
…decision format

Squashed from the stacked branch history (backup: refs/backups/pre-squash-20261118/feat/decision-planner-format).

PR: #4155
@gspencergoog
gspencergoog force-pushed the feat/decision-planner-format branch from 779498d to 4b99023 Compare November 18, 2026 17:49
gspencergoog added a commit that referenced this pull request Nov 18, 2026
…decision format

Squashed from the stacked branch history (backup: refs/backups/pre-squash-20261118/feat/decision-planner-format).

PR: #4155
@gspencergoog
gspencergoog force-pushed the feat/decision-planner-format branch from 4b99023 to bca993a Compare November 18, 2026 20:43
github-actions Bot added a commit that referenced this pull request Nov 18, 2026
gspencergoog added a commit that referenced this pull request Nov 19, 2026
…decision format

Squashed from the stacked branch history (backup: refs/backups/pre-squash-20261118/feat/decision-planner-format).

PR: #4155
@gspencergoog
gspencergoog force-pushed the feat/decision-planner-format branch from bca993a to 83f5dfc Compare November 19, 2026 02:23
github-actions Bot added a commit that referenced this pull request Nov 19, 2026
gspencergoog added a commit that referenced this pull request Nov 19, 2026
…decision format

Squashed from the stacked branch history (backup: refs/backups/pre-squash-20261118/feat/decision-planner-format).

PR: #4155
@gspencergoog
gspencergoog force-pushed the feat/decision-planner-format branch from 83f5dfc to dfa64bc Compare November 19, 2026 04:21
github-actions Bot added a commit that referenced this pull request Nov 19, 2026
…decision format

Squashed from the stacked branch history (backup: refs/backups/pre-squash-20261118/feat/decision-planner-format).

PR: #4155
…ference_formats

Remove the decision, Atom, and Elemental re-exports from the top-level a2ui.inference_formats barrel so importing the barrel never loads experimental formats or httpx. Update eval/a2ui_eval/runner.py to import AtomFormat and ElementalFormat from their experimental packages, tighten the isolated CI assertion, update READMEs and proposal docs, and record the breaking change under Unreleased in CHANGELOG.md.

Signed-off-by: Greg Spencer <gspencer@google.com>
…and parser

Signed-off-by: Greg Spencer <gspencer@google.com>
… docs

- Reject pointers containing braces in $text/$format interpolation and stop doubling literal backslashes in _escape_format_string_literal.

- Verify TemplateChildList.componentId during pruning and clean up dead optional slots / required-slot drops on multi-slot containers.

- Export extract_decision_blocks in parser.__all__ and call public extract_blocks internally.

- Fix CHANGELOG.md list indentation and align decision_inference_format.md $format and plan_shape_signature docs.

Signed-off-by: Greg Spencer <gspencer@google.com>
@gspencergoog
gspencergoog force-pushed the feat/decision-planner-format branch from dfa64bc to a049845 Compare November 24, 2026 18:01
Resolve Unreleased CHANGELOG.md conflict in python/a2ui_agent/CHANGELOG.md
by preserving breaking changes and entries from both branches.
@gspencergoog
gspencergoog marked this pull request as draft November 30, 2026 23:51
@gspencergoog

Copy link
Copy Markdown
Collaborator Author

Superseded by #4514 (ported into a2ui.experimental.decision.synthesizer on top of #4471-#4496 in stack #4501).

🤖 Agent-generated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant