|
17 | 17 | """ |
18 | 18 |
|
19 | 19 |
|
20 | | -# NOTE: approval_mode="never_require" is for sample brevity. Use "always_require" in production; see samples/getting_started/tools/function_tool_with_approval.py and samples/getting_started/tools/function_tool_with_approval_and_threads.py. |
| 20 | +# NOTE: approval_mode="never_require" is for sample brevity. Use "always_require" in production |
| 21 | +# See: |
| 22 | +# samples/getting_started/tools/function_tool_with_approval.py |
| 23 | +# samples/getting_started/tools/function_tool_with_approval_and_threads.py. |
21 | 24 | @tool(approval_mode="never_require") |
22 | 25 | def get_weather( |
23 | 26 | location: Annotated[str, Field(description="The location to get the weather for.")], |
@@ -78,19 +81,19 @@ async def example_with_thread_persistence_in_memory() -> None: |
78 | 81 | # First conversation |
79 | 82 | query1 = "What's the weather like in Tokyo?" |
80 | 83 | print(f"User: {query1}") |
81 | | - result1 = await agent.run(query1, thread=thread, store=False) |
| 84 | + result1 = await agent.run(query1, thread=thread, options={"store": False}) |
82 | 85 | print(f"Agent: {result1.text}") |
83 | 86 |
|
84 | 87 | # Second conversation using the same thread - maintains context |
85 | 88 | query2 = "How about London?" |
86 | 89 | print(f"\nUser: {query2}") |
87 | | - result2 = await agent.run(query2, thread=thread, store=False) |
| 90 | + result2 = await agent.run(query2, thread=thread, options={"store": False}) |
88 | 91 | print(f"Agent: {result2.text}") |
89 | 92 |
|
90 | 93 | # Third conversation - agent should remember both previous cities |
91 | 94 | query3 = "Which of the cities I asked about has better weather?" |
92 | 95 | print(f"\nUser: {query3}") |
93 | | - result3 = await agent.run(query3, thread=thread, store=False) |
| 96 | + result3 = await agent.run(query3, thread=thread, options={"store": False}) |
94 | 97 | print(f"Agent: {result3.text}") |
95 | 98 | print("Note: The agent remembers context from previous messages in the same thread.\n") |
96 | 99 |
|
|
0 commit comments