Improve airline agent: enum schemas, policy consistency, same-day fee fix#73
Merged
Improve airline agent: enum schemas, policy consistency, same-day fee fix#73
Conversation
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>
tara-servicenow
approved these changes
Apr 23, 2026
Collaborator
tara-servicenow
left a comment
There was a problem hiding this comment.
Looks good thanks for improving this
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
get_reservationresponses with per-segment origin/destination/scheduled times from the journeys table (read-time only, no DB impact).enum:fields so the LLM gets a hard constraint; add a two-way drift test between the YAML and the Pydantic StrEnums.transfer_to_agent.same_dayvsvoluntaryrebook 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 passedexpected_scenario_dbimpact:change_feeis response-only; no existing scenario touches the changed code paths (Business/First same-day, Basic Economy rebook)