Skip to content

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

[HOTFIX] Fix the bug of missing metadata field when finish function fail to execute in the toolkit (#783)

DavdGao97a7daddfdc0
diff --git a/src/agentscope/agent/_react_agent.py b/src/agentscope/agent/_react_agent.py
index 51fdd0ecd..f731d13d1 100644
--- a/src/agentscope/agent/_react_agent.py
+++ b/src/agentscope/agent/_react_agent.py
@@ -411,7 +411,7 @@ class ReActAgent(ReActAgentBase):
Returns:
`Union[Msg, None]`:
- Return a message to the user if the `_finish_function` is
+ Return a message to the user if the `finish_function` is
called, otherwise return `None`.
"""
@@ -443,7 +443,10 @@ class ReActAgent(ReActAgentBase):
if (
tool_call["name"] != self.finish_function_name
or tool_call["name"] == self.finish_function_name
- and not chunk.metadata.get("success")
+ and (
+ chunk.metadata is None
+ or not chunk.metadata.get("success")
+ )
):
await self.print(tool_res_msg, chunk.is_last)