Build and run agents you can see, understand and trust.
Python agentchatbotlarge-language-modelsllmllm-agentmcpmulti-agentmulti-modalreact-agentrealtime-agentvoice-agentvoice-assistant
fix(stream_printing_messages): fix the bug in stream_printing_messages pipeline (#866)
DavdGao9d4cefaeba5f
diff --git a/src/agentscope/agent/_agent_base.py b/src/agentscope/agent/_agent_base.pyindex 6a8481231..0ac03550d 100644--- a/src/agentscope/agent/_agent_base.py+++ b/src/agentscope/agent/_agent_base.py@@ -5,6 +5,7 @@ import ioimport jsonfrom asyncio import Task, Queuefrom collections import OrderedDict+from copy import deepcopyfrom typing import Callable, Anyimport base64import shortuuid@@ -205,7 +206,7 @@ class AgentBase(StateModule, metaclass=_AgentMeta):non-streaming message, this should always be `True`."""if not self._disable_msg_queue:- await self.msg_queue.put((msg, last))+ await self.msg_queue.put((deepcopy(msg), last))if self._disable_console_output:returndiff --git a/src/agentscope/agent/_react_agent.py b/src/agentscope/agent/_react_agent.pyindex 17ffc3134..39d8831f7 100644--- a/src/agentscope/agent/_react_agent.py+++ b/src/agentscope/agent/_react_agent.py@@ -387,6 +387,10 @@ class ReActAgent(ReActAgentBase):await self.print(msg, False)await self.print(msg, True)+ # Add a tiny sleep to yield the last message object in the+ # message queue+ await asyncio.sleep(0.001)+else:msg = Msg(self.name, list(res.content), "assistant")await self.print(msg, True)