Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions examples/customer-support/backend/app/airline_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ def change_seat(self, thread_id: str, flight_number: str, seat: str) -> str:
)
return f"Seat updated to {segment.seat} on flight {segment.flight_number}."

def cancel_trip(self, thread_id: str) -> str:
def cancel_trip(self, thread_id: str, flight_number: str) -> str:
profile = self.get_profile(thread_id)
for segment in profile.segments:
segment.cancel()
segment = self._find_segment(profile, flight_number)
if segment is None:
raise ValueError(f"Flight {flight_number} is not on the customer's itinerary.")
segment.cancel()
profile.log("Trip cancelled at customer request.", kind="warning")
return "The reservation has been cancelled. Refund processing will begin immediately."

Expand Down
9 changes: 6 additions & 3 deletions examples/customer-support/backend/app/support_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

Available tools:
- change_seat(flight_number: str, seat: str) – move the passenger to a new seat.
- cancel_trip() – cancel the upcoming reservation and note the refund.
- cancel_trip(flight_number: str) – cancel the upcoming reservation and note the refund.
- add_checked_bag() – add one checked bag to the itinerary.
- meal_preference_list() – show meal options so the traveller can pick their preference.
Invoke this tool when the user requests to set or change their meal preference or option.
Expand Down Expand Up @@ -63,8 +63,11 @@ async def change_seat(
@function_tool(
description_override="Cancel the traveller's upcoming trip and note the refund.",
)
async def cancel_trip(ctx: RunContextWrapper[AgentContext]) -> Dict[str, str]:
message = state_manager.cancel_trip(_thread_id(ctx))
async def cancel_trip(ctx: RunContextWrapper[AgentContext], flight_number: str) -> Dict[str, str]:
try:
message = state_manager.cancel_trip(_thread_id(ctx), flight_number)
except ValueError as exc: # translate user errors
raise ValueError(str(exc)) from exc
return {"result": message}

@function_tool(
Expand Down