Skip to content

Improve airline agent: enum schemas, policy consistency, same-day fee fix#73

Merged
gabegma merged 5 commits intomainfrom
ggm/improve-airline
Apr 23, 2026
Merged

Improve airline agent: enum schemas, policy consistency, same-day fee fix#73
gabegma merged 5 commits intomainfrom
ggm/improve-airline

Conversation

@gabegma
Copy link
Copy Markdown
Collaborator

@gabegma gabegma commented Apr 23, 2026

Summary

  • Enrich get_reservation responses with per-segment origin/destination/scheduled times from the journeys table (read-time only, no DB impact).
  • Promote enum-valued tool params to proper JSON Schema enum: fields so the LLM gets a hard constraint; add a two-way drift test between the YAML and the Pydantic StrEnums.
  • Require caller confirmation before invoking transfer_to_agent.
  • Make standby policy consistent: free for all fare classes; drop the unexercised Basic Economy exclusion and the now-meaningless elite standby-fee waivers.
  • Fix same_day vs voluntary rebook fees: Basic Economy now pays $199 same-day / $75 voluntary; Business/First pay $75 same-day / $0 voluntary. Clarify in instructions when to pick each.

Test plan

  • pytest tests/unit/airline/ — 110 passed
  • New drift test catches YAML↔Pydantic enum mismatches (verified by intentionally leaving one out)
  • Verified no expected_scenario_db impact: change_fee is response-only; no existing scenario touches the changed code paths (Business/First same-day, Basic Economy rebook)

gabegma and others added 5 commits April 22, 2026 20:31
Merge origin/destination/scheduled_departure/scheduled_arrival from the
journeys table onto booking segments so the agent has ticket-level
schedule info without a second tool call. Operational status
(delayed/cancelled) is intentionally excluded — that remains the
responsibility of get_flight_status.

Enrichment runs on a deepcopy, so no DB state is mutated and
task_completion hashes are unaffected.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move the allowed-value lists out of prose descriptions and into the
YAML `enum:` field on airline_agent.yaml, so the LLM receives a hard
schema constraint (enforced under strict structured output) rather than
a soft hint. Covers rebooking_type, fare_class, new_fare_class,
seat_preference, meal_type, credit_reason, voucher_reason, refund_type,
and cancellation_reason.

`cancellation_reason` is also promoted from a plain `str` to a new
`CancellationReason` StrEnum on the Pydantic side. The
cancel_reservation tool now does equality comparisons against enum
values instead of substring matches, eliminating a class of false
positives (e.g. "irrops_refund_foo" matching "irrops_refund").

Adds tests/unit/airline/test_agent_yaml_enums.py — a two-way drift
guard that asserts the YAML `enum:` values match the corresponding
Pydantic StrEnum values, in both directions. Keeps the two
hand-maintained sources of truth in sync going forward.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds explicit instruction under Escalation Policy to offer the transfer
first and wait for the caller's confirmation before initiating. Prevents
the agent from invoking the transfer tool mid-conversation without an
affirmative signal from the caller.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Resolve contradictions between Change Fees, Standby Rules, and Elite
Status Benefits sections — all three described slightly different
standby rules. Audit of data/airline_dataset.jsonl standby scenarios
(3.1.3, 4.2.1, 4.2.4, 4.2.5) shows every expected flow treats standby
as free, none exercise a Basic Economy exclusion, and the add_to_standby
tool itself charges no fees. Align the instructions with actual behavior.

- Standby Rules: standby is free for all passengers / all fare classes;
  drop the Basic Economy exclusion (unexercised, unenforced).
- Change Fees: point to Standby Rules instead of restating the policy.
- Elite Status Benefits: drop "Waived same-day standby fee" lines for
  Silver / Gold / Platinum — there is no fee to waive.

Priority Order (exercised by scenario 4.2.5 for Gold), Clearing rules,
and the same-day + confirmed-seat eligibility constraints are preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The rebook_flight tool previously routed same_day through the voluntary
fee_map, which had basic_economy=$199 and business/first=$0. That
silently diverged from the intended policy in two ways: basic_economy
got the $199 voluntary fee applied to same-day changes (accidentally
right when you want to penalize same-day basics, but for the wrong
reason), and business/first got free same-day changes (wrong — same-day
is flat $75 for every paid class above Basic Economy).

New policy (tool + instructions):

           | Voluntary | Same-day
basic      | $75       | $199
main       | $75       | $75
premium    | $75       | $75
business   | $0        | $75
first      | $0        | $75

IRROPS and explicit waive_change_fee still zero everything. Gold and
Platinum waivers remain agent-driven via waive_change_fee=True — the
tool does not enforce elite status (consistent with how cancellation_
reason-driven fee waivers work; divergence is caught by task_completion
hashing expected_scenario_db).

The instructions now also make explicit that same_day is a subtype of
voluntary distinguished by timing ("new flight departs today"), so the
agent knows which rebooking_type to pick.

No DB impact: change_fee / total_collected / fare_difference only
appear in the response cost_summary — no DB write depends on them.
Verified by tracing every DB mutation in rebook_flight (fare_paid,
booking status, reservation status, seat availability) — all branch on
is_irrops, target_fare_class, or original_fare_class, none on fee
values. No existing scenario's expected_scenario_db is affected.

Adds 6 new unit tests covering all 4 cells where behavior changed
(basic voluntary $75, basic same-day $199, business same-day $75,
business voluntary $0) plus the Gold+ waiver path for basic same-day.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@gabegma gabegma self-assigned this Apr 23, 2026
Copy link
Copy Markdown
Collaborator

@tara-servicenow tara-servicenow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good thanks for improving this

@gabegma gabegma added this pull request to the merge queue Apr 23, 2026
Merged via the queue into main with commit 25c05b1 Apr 23, 2026
1 check passed
@gabegma gabegma deleted the ggm/improve-airline branch April 23, 2026 18:20
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.

2 participants