A2UI
A2UI copied to clipboard
Reduce restaurant UI prompt with minimal A2UI contract
Summary
Replaces the full embedded A2UI schema in the restaurant finder prompt with a short “A2UI JSON contract”. This keeps format guidance while significantly reducing prompt size and token usage.
Changes
- Add a minimal A2UI JSON contract block to the UI prompt.
- Remove the full schema block from the prompt (schema validation remains server-side).
Impact
Prompt length reduced from 48,356 → 13,853 characters (~71.3% reduction).
Testing
- Not run (prompt-only change).
Note: Full A2UI JSON schema validation is enforced server-side; this change only affects the LLM prompt.
How measured
# PowerShell (Windows)
@'
import importlib.util, sys
from pathlib import Path
folder = Path("samples/agent/adk/restaurant_finder").resolve()
sys.path.insert(0, str(folder))
path = folder / "prompt_builder.py"
spec = importlib.util.spec_from_file_location("prompt_builder", path)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
text = mod.get_ui_prompt("http://localhost:8000", mod.RESTAURANT_UI_EXAMPLES)
print(len(text))
'@ | python -
# ----------------------------------------
# bash (macOS / Linux)
python - <<'PY'
import importlib.util, sys
from pathlib import Path
folder = Path('samples/agent/adk/restaurant_finder').resolve()
sys.path.insert(0, str(folder))
path = folder / 'prompt_builder.py'
spec = importlib.util.spec_from_file_location('prompt_builder', path)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
text = mod.get_ui_prompt(
'http://localhost:8000',
mod.RESTAURANT_UI_EXAMPLES,
)
print(len(text))
PY