feat(c-a2ui): Modify search prefills form with prior submit context#454
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Follow-up to PR #411 (confirmation surface). After Select → confirmation → 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 and forcing re-entry.
Was listed as an explicit out-of-scope follow-up in PR #411's design doc; landing it now closes the loop.
How it works
build_formwalks message history via the existing_extract_prior_submit_contexthelper (also used byconfirm_booking)_form_defaults_from_prior(prior)projects the prior context onto the form'sdata_modelschema (origin/dest/date/passengers/fare_class), filling missing keys from_BLANK_FORM_DEFAULTSand normalizing passengers to int_BUILD_FORM_SYSTEMprompt becomes_BUILD_FORM_SYSTEM_TMPLwith a__DATA_MODEL_DEFAULTS__sentinel substituted per-call viastr.replace(avoided.format()because the prompt has many literal-brace JSON examples that would conflict with brace escaping)_SENTINEL_BOOKING_FORMconstant becomes_build_sentinel_booking_form(defaults)so the fallback path also respects prefillBehavior matrix
Files
cockpit/chat/a2ui/python/src/graph.py— single file, single capability changeTest plan
dataModelUpdate.contentscarries LAX/JFK/2026-06-15/2/Businesspnpm nx run cockpit-chat-a2ui-python:build— green🤖 Generated with Claude Code