From 81354df48b2ff32998bdc8b5421acf044223fe92 Mon Sep 17 00:00:00 2001 From: Ariel Frischer Date: Fri, 14 Feb 2025 14:45:33 -0800 Subject: [PATCH] fix(ciayn_agent.py): correct spelling of "execute" in error message for clarity refactor(ciayn_agent.py): improve error handling by chaining exceptions for better debugging docs(output.py): update docstring to include agent_type parameter for clarity on agent behavior --- ra_aid/agents/ciayn_agent.py | 6 ++++-- ra_aid/console/output.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ra_aid/agents/ciayn_agent.py b/ra_aid/agents/ciayn_agent.py index 8d1393f..af93458 100644 --- a/ra_aid/agents/ciayn_agent.py +++ b/ra_aid/agents/ciayn_agent.py @@ -153,9 +153,11 @@ class CiaynAgent: result = eval(code.strip(), globals_dict) return result except Exception as e: - error_msg = f"Error: {str(e)} \n Could not excute code: {code}" + error_msg = f"Error: {str(e)} \n Could not execute code: {code}" tool_name = self.extract_tool_name(code) - raise ToolExecutionError(error_msg, base_message=msg, tool_name=tool_name) + raise ToolExecutionError( + error_msg, base_message=msg, tool_name=tool_name + ) from e def extract_tool_name(self, code: str) -> str: match = re.match(r"\s*([\w_\-]+)\s*\(", code) diff --git a/ra_aid/console/output.py b/ra_aid/console/output.py index 3dc9f1d..dfba0a8 100644 --- a/ra_aid/console/output.py +++ b/ra_aid/console/output.py @@ -16,7 +16,8 @@ def print_agent_output( """Print only the agent's message content, not tool calls. Args: - chunk: A dictionary containing agent or tool messages + chunk: A dictionary containing agent or tool messages. + agent_type: Specifies the type of agent. 'CiaynAgent' handles tool errors internally, while 'React' raises a ToolExecutionError. """ if "agent" in chunk and "messages" in chunk["agent"]: messages = chunk["agent"]["messages"]