Removed list_messages method from thread (#564)

This commit is contained in:
Dmytro Struk
2025-08-29 15:51:52 -07:00
committed by GitHub
Unverified
parent a80db062b2
commit 2037e533b3
8 changed files with 16 additions and 33 deletions
@@ -67,21 +67,18 @@ async def example_with_thread_persistence_in_memory() -> None:
print(f"User: {query1}")
result1 = await agent.run(query1, thread=thread)
print(f"Agent: {result1.text}")
print(f"Thread contains {len(await thread.list_messages() or [])} messages in-memory.")
# Second conversation using the same thread - maintains context
query2 = "How about London?"
print(f"\nUser: {query2}")
result2 = await agent.run(query2, thread=thread)
print(f"Agent: {result2.text}")
print(f"Thread contains {len(await thread.list_messages() or [])} messages in-memory.")
# Third conversation - agent should remember both previous cities
query3 = "Which of the cities I asked about has better weather?"
print(f"\nUser: {query3}")
result3 = await agent.run(query3, thread=thread)
print(f"Agent: {result3.text}")
print(f"Thread contains {len(await thread.list_messages() or [])} messages in-memory.")
print("Note: The agent remembers context from previous messages in the same thread.\n")
@@ -111,7 +108,6 @@ async def example_with_existing_thread_id() -> None:
# Enable Azure OpenAI conversation state by setting `store` parameter to True
result1 = await agent.run(query1, thread=thread, store=True)
print(f"Agent: {result1.text}")
print(f"Thread contains {len(await thread.list_messages() or [])} messages in-memory.")
# The thread ID is set after the first response
existing_thread_id = thread.service_thread_id
@@ -133,7 +129,6 @@ async def example_with_existing_thread_id() -> None:
print(f"User: {query2}")
result2 = await agent.run(query2, thread=thread, store=True)
print(f"Agent: {result2.text}")
print(f"Thread contains {len(await thread.list_messages() or [])} messages in-memory.")
print("Note: The agent continues the conversation from the previous thread by using thread ID.\n")