mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Removed list_messages method from thread (#564)
This commit is contained in:
committed by
GitHub
Unverified
parent
a80db062b2
commit
2037e533b3
@@ -632,7 +632,8 @@ class ChatClientAgent(AgentBase):
|
||||
messages: list[ChatMessage] = []
|
||||
if self.instructions:
|
||||
messages.append(ChatMessage(role=ChatRole.SYSTEM, text=self.instructions))
|
||||
messages.extend(await thread.list_messages() or [])
|
||||
if thread.message_store:
|
||||
messages.extend(await thread.message_store.list_messages() or [])
|
||||
messages.extend(input_messages or [])
|
||||
return thread, messages
|
||||
|
||||
|
||||
@@ -138,10 +138,6 @@ class AgentThread(AFBaseModel):
|
||||
|
||||
self._message_store = message_store
|
||||
|
||||
async def list_messages(self) -> list[ChatMessage] | None:
|
||||
"""Retrieves any messages stored in ChatMessageStore of the thread, otherwise returns an empty collection."""
|
||||
return await self._message_store.list_messages() if self._message_store is not None else None
|
||||
|
||||
async def serialize(self, **kwargs: Any) -> dict[str, Any]:
|
||||
"""Serializes the current object's state.
|
||||
|
||||
|
||||
@@ -227,8 +227,9 @@ async def test_chat_client_agent_update_thread_messages(chat_client: ChatClient)
|
||||
assert result.text == "test response"
|
||||
|
||||
assert thread.service_thread_id is None
|
||||
assert thread.message_store is not None
|
||||
|
||||
chat_messages: list[ChatMessage] | None = await thread.list_messages()
|
||||
chat_messages: list[ChatMessage] = await thread.message_store.list_messages()
|
||||
|
||||
assert chat_messages is not None
|
||||
assert len(chat_messages) == 2
|
||||
|
||||
@@ -122,7 +122,9 @@ class TestAgentThread:
|
||||
store = ChatMessageList(sample_messages)
|
||||
thread = AgentThread(message_store=store)
|
||||
|
||||
messages: list[ChatMessage] | None = await thread.list_messages()
|
||||
assert thread.message_store is not None
|
||||
|
||||
messages: list[ChatMessage] = await thread.message_store.list_messages()
|
||||
|
||||
assert messages is not None
|
||||
assert len(messages) == 3
|
||||
@@ -134,9 +136,7 @@ class TestAgentThread:
|
||||
"""Test get_messages when no message_store is set."""
|
||||
thread = AgentThread()
|
||||
|
||||
messages: list[ChatMessage] | None = await thread.list_messages()
|
||||
|
||||
assert messages is None
|
||||
assert thread.message_store is None
|
||||
|
||||
async def test_on_new_messages_with_service_thread_id(self, sample_message: ChatMessage) -> None:
|
||||
"""Test _on_new_messages when service_thread_id is set (should do nothing)."""
|
||||
|
||||
Reference in New Issue
Block a user