feat(inference_format): A2UI Atom Inference Format#2056
Merged
Conversation
…ormat Add the experimental A2UI Atom inference format, providing an S-expression (Lisp-style parenthesized AST) model-optimized format for declarative UI generation. Key highlights: - Implement AtomCompiler, AtomDecompiler, AtomParser, AtomPromptGenerator, and AtomFormat under a2ui.inference_formats.experimental.atom. - Parent container pre-emission enabling top-down layout streaming. - Positional child unwrapping and catalog-agnostic relative path resolution. - Compact rule prompts with <a2ui> and </a2ui> sentinel tags. - Achieves -68.0% non-reasoning token reduction vs raw A2UI JSON and -52.9% TTFC emission latency reduction vs Express. - Complete proposal technical specification (specification/proposals/atom/a2ui_atom.md) and examples. - Comprehensive test coverage (test_atom_format.py, test_prompt_examples.py, test_specification_roundtrip.py) with 773 passing unit tests. - 52 automated optimization runs archived in eval/iterative/history/ with metadata-based evaluation scoring.
gspencergoog
force-pushed
the
atom_format
branch
from
July 21, 2026 09:38
e1280f3 to
53d1272
Compare
…lities - Split monolithic optimize_format.py into dedicated submodules under eval/iterative/utils/ (runner, reporter, archiver, format_tools). - Add single-command CLI utilities: --compile, --parse, --decompile, and --archive. - Add Quick-Command Cheatsheet and anti-pattern guardrails to agent_instructions.md. - Document design architecture in eval/iterative/PLAN_ITERATION_IMPROVEMENTS.md. - Add unit tests in eval/tests/test_utils.py.
…% coverage - Add test cases for Atom format prompt generator, catalog wrapper, parser, and compiler edge cases. - Add test cases for Elemental format compiler, decompiler, expression parser, and prompt generator. - Add test cases for Express format compiler, decompiler, schema helper, and prompt generator. - Add test cases for Transport format parser methods and complete tag verification. - Achieve >= 90% code coverage across all modules under a2ui.inference_formats.
…transport formats - Replace loose assertIn assertions with exact equality assertions for elemental actions. - Replace tautological streaming chunk assertions with exact ResponsePart verification for transport format. - Add negative key assertions for express _set_nested_path edge cases.
…chema wrapper - Remove hardcoded component list fallbacks in CatalogSchemaHelperWrapper to enforce explicit catalog configuration. - Restrict exception handling in CatalogSchemaHelperWrapper.__init__ to avoid masking catalog initialization errors. - Update unit tests to reflect explicit catalog requirement.
…n parser and decompiler - Use json.loads in SExprParser._parse_atom to safely unescape Unicode and emoji string literals without UTF-8 byte corruption. - Implement strict positional token scanner in SExprParser._tokenize for gap validation and unclosed string auto-healing. - Flatten child node resolution in AtomDecompiler for linear runtime root identification. - Add unit tests for SExprParser Unicode and multiline string parsing.
…and repo root resolution
…odule and update eval strategy docstrings - Extract CatalogSchemaHelper into shared a2ui.schema.schema_helper module. - Update AtomFormat prompt generator and compiler schema wrappers to import CatalogSchemaHelper from a2ui.schema. - Document atom strategy in eval _get_strategy docstring.
…eservation and hyphenated paths - Preserve exact string values in _clean_data_value to prevent bracket stripping and integer type coercion of string data. - Update KEYWORD_VAL, KEYWORD, and PATH regexes to support hyphens in path names and keywords. - Cache AtomFormat._parser instance.
…a.__init__ to prevent build hook failure - Remove eager schema_helper import from a2ui.schema.__init__ to prevent hatchling build hook ModuleNotFoundError during isolated package build setup. - Add safe Catalog import fallback in schema_helper.
…ict mypy compliance - Add explicit type annotations for instance dictionaries in CatalogSchemaHelper. - Annotate _find_enum helper function and return types to satisfy mypy strict type checks.
…cross Atom modules - Add dedicated README.md for Atom S-expression inference format package. - Document Inference Formats section in main python SDK README.md. - Add comprehensive Google-style docstrings across AtomFormat, AtomParser, AtomCompiler, AtomDecompiler, and AtomPromptGenerator.
… python SDK README
gspencergoog
marked this pull request as ready for review
July 21, 2026 21:29
…m format - Document comment notation, attribute assignment shorthand, primitive auto-wrapping, and map/list initializers in (data ...). - Detail supported validation, logic, and formatting functions. - Update action event and RPC function call syntax. - Align compilation example and JSON payload with standard basic catalog schema output.
jacobsimionato
approved these changes
Jul 24, 2026
| (ListComponent :items $/items :template (template item (ChildComponent :title $/item/name)))) | ||
| </a2ui> | ||
|
|
||
| 11. Strict Catalog Adherence & Conciseness: |
Collaborator
There was a problem hiding this comment.
Wow, I'm shocked how relatively simple the prompt is to get quite good inference performance!!
Collaborator
Author
There was a problem hiding this comment.
Yes, me too, but it does require a lot of reasoning: that's the downfall of this one, I think.
gspencergoog
enabled auto-merge (squash)
July 24, 2026 16:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR introduces the Atom Inference Format for A2UI—a compact, Lisp-inspired symbolic S-expression representation for generating A2UI v1.0 surface declarations—along with the complete 52-run iterative optimization suite and framework.
The Atom format eliminates verbose node identifiers, explicit JSON schema scaffolding, and line-by-line variable declarations (
var = Component(...)), compiling directly into valid A2UI v1.0 JSON payloads via a catalog-agnostic compiler (AtomCompiler).Format Example: Standard A2UI v1.0 JSON vs A2UI Atom
Standard A2UI v1.0 JSON
{ "version": "v1.0", "createSurface": { "surfaceId": "main", "catalogId": "basic", "components": [ { "id": "root", "component": "Card", "child": "col_1" }, { "id": "col_1", "component": "Column", "children": ["title_1", "desc_1", "btn_1"] }, { "id": "title_1", "component": "Text", "text": "Order Confirmed!", "variant": "h2" }, { "id": "desc_1", "component": "Text", "text": "Your package #12345 will arrive tomorrow." }, { "id": "btn_1", "component": "Button", "label": "Track Order", "onClick": { "name": "trackPackage", "context": { "orderId": "12345" } } } ] } }Equivalent A2UI Atom S-Expression
<a2ui> (Card (Column (Text "Order Confirmed!" :variant "h2") "Your package #12345 will arrive tomorrow." (Button "Track Order" :onClick (Event "trackPackage" :orderId "12345")))) </a2ui>Benchmark Results & Key Metrics (Atom vs Raw JSON & Express)
Evaluated across representative UI dataset prompts on
google/gemini-3.5-flash:transport)express)Highlights of Optimizations Included
Across 52 automated serial optimization runs:
AtomCompiler._compile_component._auto_wrap_text_child).:contextS-expression maps and parameterless event context maps (context: {}omission, Run 33).Testing & Verification
772 passed(100% pass rate).test_fuzzed_synthetic_catalog_agnosticismpassed (100% compliant).patch.diff,report.md,run_meta.json,results.json) archived undereval/iterative/history/and indexed inhistory_summary.md.