I’m building a booking assistant using LangGraph with a supervisor and booking agent. My issue is that the booking agent immediately transfers control back to the supervisor instead of gathering necessary booking information from the user.
Current behavior:
- Supervisor transfers to booking agent
- Booking agent immediately transfers back without gathering context
- No opportunity to ask essential booking questions (dates, preferences, etc.)
Expected behavior:
- Booking agent should maintain control
- Ask series of questions to gather booking context
- Only transfer back after collecting all necessary information and completing the booking
Interesting note: This works correctly when using custom LangGraph implementation with explicit handoffs defined in a state graph, but fails with the prebuilt supervisor pattern.
Simplified code:
booking_agent = create_react_agent(
model=llm,
tools=[check_availability, make_booking, cancel_booking],
prompt="You are a booking agent. Gather all necessary information before making a booking",
name="booking_agent",
)
supervisor = create_supervisor(
model=model,
agents=[booking_agent],
prompt="Transfer booking questions to booking agent, let it handle full conversation",
add_handoff_back_messages=True,
).compile()
How can I prevent the immediate transfer back and allow the agent to gather all necessary context through conversation before using its tools?