-
Notifications
You must be signed in to change notification settings - Fork 686
Description
Python Version: 3.13.3
AgentFramework Version: 1.0.0b251105
Code:
·····
store = RedisChatMessageStore(
redis_url="redis://127.0.0.1:6379",
thread_id="678901",
)
·····
agent = azure_client.create_agent(
name="chat_agent",
instructions="You are a helpful assistant.",
model_id= "gpt-4.1",
tools=[get_location,get_location_time],
# chat_message_store_factory=lambda: store,
)
thread = agent.get_new_thread()
thread_1 = AgentThread(message_store=store)
user = input("请输入: ")
while True:
print("round: ",round," user: ",user)
response = await agent.run(
messages=user,
thread=thread_1,
)
if response.user_input_requests:
for user_input_needed in response.user_input_requests:
print(f"Approval needed for: {user_input_needed.function_call.name}")
print(f"Arguments: {user_input_needed.function_call.arguments}")
print("we will wait for your input,yes/no:")
user_input = input()
user_approval = False
if user_input.lower() == "yes":
await thread_1.on_new_messages(ChatMessage(role=Role.USER, contents=[user_input_needed.create_response(True)]))
else:
await thread_1.on_new_messages(ChatMessage(role=Role.USER, contents=[user_input_needed.create_response(False)]))
continue
else:
if response.messages[0].contents[0].type == "text":
print("agent response: ",response.messages[0].contents[0].text)
else:
print("agent response: ",response.to_json(indent=2))
serialized_thread = await thread_1.serialize()
Error:
File "/opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 719, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/Users/worker/workspace/project/agent-framework-demo/chatagent_redisstore_demo.py", line 93, in chat_demo
serialized_thread = await thread_1.serialize()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/worker/workspace/project/agent-framework-demo/venv/lib/python3.13/site-packages/agent_framework/_threads.py", line 430, in serialize
state = AgentThreadState(
service_thread_id=self._service_thread_id, chat_message_store_state=chat_message_store_state
)
File "/Users/worker/workspace/project/agent-framework-demo/venv/lib/python3.13/site-packages/agent_framework/_threads.py", line 175, in init
self.chat_message_store_state = ChatMessageStoreState.from_dict(chat_message_store_state)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/worker/workspace/project/agent-framework-demo/venv/lib/python3.13/site-packages/agent_framework/_serialization.py", line 552, in from_dict
return cls(**kwargs)
File "/Users/worker/workspace/project/agent-framework-demo/venv/lib/python3.13/site-packages/agent_framework/_threads.py", line 144, in init
raise TypeError("Messages should be a list")
TypeError: Messages should be a list