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
This commit is contained in:
Ariel Frischer 2025-02-14 14:45:33 -08:00
parent 4a2a0b691c
commit 81354df48b
2 changed files with 6 additions and 3 deletions

View File

@ -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)

View File

@ -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"]