A travel-planner Agent walks through five turns of a single conversation: kicking off the trip, layering on budget and travel-mode constraints, swapping a day's activity, and producing a final itinerary summary. Each turn uses reply.ask() so the conversation context (constraints from earlier turns) carries forward without the caller re-supplying it.
"""03 · Travel planner — multi-turn conversationChained ``reply.ask()`` builds on the same conversation history. The plannerremembers constraints from earlier turns without the caller re-supplyingcontext each time — the stream stays alive across the whole dialogue.Run:: .venv-beta/bin/python 03_travel_planner.py"""importasynciofromautogen.betaimportAgentfromautogen.beta.configimportGeminiConfigdefsection(title:str)->None:print(f"\n── {title} ───")TURNS=["I want to plan a 5-day trip to Japan in late April. Just cherry-blossom season.","Budget is around $2500 per person, two travellers. Optimise for sightseeing, not luxury.","We prefer trains to flights once we're in Japan. Draft a day-by-day itinerary.","Looks great. For day 3, swap the shopping stop for something outdoorsy in or near Kyoto.","Summarize the final itinerary in a single bullet list, one line per day.",]asyncdefmain()->None:config=GeminiConfig(model="gemini-3-flash-preview",temperature=0)agent=Agent("travel-planner",prompt=("You are a detail-oriented travel planner. When the user adds ""constraints, update the plan rather than starting over. Be ""concrete and concise."),config=config,)section("Turn 1 — kick off")reply=awaitagent.ask(TURNS[0])print(reply.body)fori,questioninenumerate(TURNS[1:],start=2):section(f"Turn {i} — {question}")reply=awaitreply.ask(question)print(reply.body)if__name__=="__main__":asyncio.run(main())