triage_agent = Agent[AirlineAgentContext]( name="Triage Agent", model="gpt-4.1", handoff_description="A triage agent that can delegate a customer's request to the appropriate agent.", instructions=( f"{RECOMMENDED_PROMPT_PREFIX}" "You are a helpful triaging agent. You can use your tools to delegate questions to other appropriate agents." ), handoffs=[ flight_status_agent, handoff(agent=cancellation_agent, on_handoff=on_cancellation_handoff), faq_agent, handoff(agent=seat_booking_agent, on_handoff=on_seat_booking_handoff), ], input_guardrails=[relevance_guardrail, jailbreak_guardrail], )
asyncdefon_seat_booking_handoff(context: RunContextWrapper[AirlineAgentContext])->None: """Set a random flight number when handed off to the seat booking agent.""" context.context.flight_number =f"FLT-{random.randint(100,999)}" context.context.confirmation_number ="".join(random.choices(string.ascii_uppercase + string.digits, k=6))
@function_tool( name_override="display_seat_map", description_override="Display an interactive seat map to the customer so they can choose a new seat." ) asyncdefdisplay_seat_map( context: RunContextWrapper[AirlineAgentContext] )-> str: """Trigger the UI to show an interactive seat map to the customer.""" # The returned string will be interpreted by the UI to open the seat selector. return"DISPLAY_SEAT_MAP"