Skip to content

fix(c-a2ui): seed booking form origin/dest from prompt to ensure happy path#467

Merged
blove merged 1 commit into
mainfrom
claude/c-a2ui-prompt-seed
May 19, 2026
Merged

fix(c-a2ui): seed booking form origin/dest from prompt to ensure happy path#467
blove merged 1 commit into
mainfrom
claude/c-a2ui-prompt-seed

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented May 19, 2026

Summary

The welcome chips ('I want to fly LAX to JFK', 'I want to fly SFO to SEA') trigger build_form, but on a fresh first turn the form's data_model carries blank defaults — and the LLM occasionally extracts the wrong values from the prompt (commonly sets both origin AND dest to LAX, which finds zero flights because the in-memory _FLIGHTS dataset has no same-airport routes).

Result: user clicks a chip → sees a form → clicks Search → empty results bubble. Failure path is the default path.

Fix

Deterministic regex pre-pass _seed_airports_from_messages walks the message history for the most recent human prompt and extracts an (origin, dest) IATA pair when the prompt explicitly names one ('LAX to JFK' / 'lax → jfk' / 'SFO -> SEA'). build_form seeds the form's data_model with those values whenever there's no prior bookingSubmit context to draw from.

The LLM still authors the spec; only the field default values get pre-filled deterministically.

Guard rails

  • Only matches IATA codes in AIRPORT_CODES — never seeds an airport the form's dropdown can't render
  • Same-origin/dest pairs (LAX → LAX) are skipped (no flights match)
  • Only inspects human-role messages; action JSON + AI surfaces filtered
  • Prior-context path unchanged: Modify-search after a real submit still prefills from the submitted values, not the original prompt

Files

  • cockpit/chat/a2ui/python/src/graph.py_seed_airports_from_messages helper + one-line call in build_form

Test plan

  • 11 unit cases pass: chip prompts (both), arrow notation ( and ->), case-insensitive, same-airport guard, unknown airports, AI-message filter, action-JSON filter, most-recent-wins
  • Real-LLM end-to-end smoke: chip prompt → form has Origin=LAX, Dest=JFK → submit → results surface contains UA123 (the LAX→JFK flight)
  • npx nx run cockpit-chat-a2ui-python:build — green
  • CI

🤖 Generated with Claude Code

…y path

The welcome chips ("I want to fly LAX to JFK", "I want to fly SFO to
SEA") trigger build_form, but on a fresh first turn the form's
data_model carries blank defaults — and the LLM occasionally extracts
the wrong values from the prompt (commonly sets both origin AND dest
to LAX, which finds zero flights because the in-memory _FLIGHTS dataset
has no same-airport routes).

Add a deterministic regex pre-pass: `_seed_airports_from_messages`
walks the message history for the most recent human prompt and
extracts an (origin, dest) airport pair when the prompt explicitly
names one ("LAX to JFK" / "lax → jfk" / "SFO -> SEA"). build_form
uses those values to seed the form's data_model whenever there's no
prior bookingSubmit context to draw from. The LLM still authors the
spec but the field defaults are now correct.

Guard rails:
- Only matches IATA codes that appear in AIRPORT_CODES — never seeds
  an airport the form's dropdown can't render
- Same-origin/dest pairs (LAX → LAX) are skipped (no flights match)
- Only inspects human-role messages; action-message JSON and AI
  surfaces are filtered out
- Prior-context path is unchanged: a Modify-search after a real submit
  still prefills from the submitted values, not the original prompt

Verified end-to-end via real-LLM smoke:
  HumanMessage('I want to fly LAX to JFK')
    → form data_model = {origin: LAX, dest: JFK, ...}
    → bookingSubmit with LAX/JFK
    → results surface contains UA123 (the LAX→JFK flight in _FLIGHTS)

Plus 11 unit cases for the seed helper: chip prompts, arrow notation,
case-insensitive, same-airport guard, unknown airports, AI-message
filter, action-JSON filter, most-recent-wins.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
threadplane Ready Ready Preview, Comment May 19, 2026 5:14pm

Request Review

@blove blove merged commit abba9c4 into main May 19, 2026
18 checks passed
@blove blove deleted the claude/c-a2ui-prompt-seed branch May 19, 2026 17:22
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