Skip to content

Build and run agents you can see, understand and trust.

fix(ReActAgent): filter `None` values when joining the message text content in the retrieval function (#1041)

qbcd3c0c1d0ba66
diff --git a/src/agentscope/agent/_react_agent.py b/src/agentscope/agent/_react_agent.py
index 3b0dc0607..c9cf29978 100644
--- a/src/agentscope/agent/_react_agent.py
+++ b/src/agentscope/agent/_react_agent.py
@@ -775,7 +775,12 @@ class ReActAgent(ReActAgentBase):
if isinstance(msg, Msg):
query = msg.get_text_content()
elif isinstance(msg, list):
- query = "\n".join(_.get_text_content() for _ in msg)
+ texts = []
+ for m in msg:
+ text = m.get_text_content()
+ if text:
+ texts.append(text)
+ query = "\n".join(texts)
# Skip if the query is empty
if not query: