You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(c-a2ui): Modify search prefills form with prior submit context (#454)
After Select → confirmation surface → Modify search, the booking form
re-renders with the user's prior origin/dest/date/passengers/fare_class
already populated as the field defaults — instead of starting blank.
Today's flow: Modify search routes back through build_form which emits
the spec with hardcoded blank data_model. The render is correct but
forces the user to re-enter every field. Now build_form walks the
message history via the existing _extract_prior_submit_context helper
and seeds the form's data_model with whatever values the most recent
bookingSubmit carried.
Implementation:
- Convert _BUILD_FORM_SYSTEM (constant) to _BUILD_FORM_SYSTEM_TMPL with
a non-brace sentinel __DATA_MODEL_DEFAULTS__ that build_form()
substitutes per call via str.replace (.format() would conflict with
the many literal-brace JSON examples in the prompt).
- Convert _SENTINEL_BOOKING_FORM (constant) to _build_sentinel_booking_form(defaults),
so the sentinel honors prefilled values too — Modify search shouldn't
blank the form if the LLM happens to retry-exhaust.
- New _form_defaults_from_prior helper projects the prior context dict
onto the form's data_model schema, falling back to _BLANK_FORM_DEFAULTS
for any missing keys and normalizing passengers to int.
- build_form now: extract prior → compute defaults → render prompt
with those defaults → emit spec.
Verified via 3-turn programmatic real-LLM smoke:
submit(LAX→JFK, 2 pax, Business) → flightSelect(UA123) → modifySearch
→ form data_model = {origin:LAX, dest:JFK, date:2026-06-15,
passengers:2, fare_class:Business}
First-turn blank case still emits blank defaults (regression check).
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
# `__DATA_MODEL_DEFAULTS__` is a non-brace sentinel substituted at call-time
279
+
# by `build_form()` via `str.replace()` — using `.format()` would conflict
280
+
# with the many literal-brace JSON examples below.
281
+
_BUILD_FORM_SYSTEM_TMPL=f"""You are an aviation booking-form designer. Emit an A2UI v1 booking form using the structured output schema.
269
282
270
283
A2UI FORMAT (CRITICAL): each component is `{{"id": "...", "component": {{"<ComponentName>": {{<props>}}}}}}`. The component name is the SINGLE KEY of the inner dict. ComponentName must be one of:
0 commit comments