AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(agent/logging): Log warning when action raises error
Reinier van der Leerefb5fed46281
diff --git a/autogpts/autogpt/autogpt/agents/agent.py b/autogpts/autogpt/autogpt/agents/agent.pyindex 88e6a46ed5..bcb4d1a799 100644--- a/autogpts/autogpt/autogpt/agents/agent.py+++ b/autogpts/autogpt/autogpt/agents/agent.py@@ -26,6 +26,7 @@ from autogpt.logs.log_cycle import (USER_INPUT_FILE_NAME,LogCycleHandler,)+from autogpt.logs.utils import fmt_kwargsfrom autogpt.models.action_history import (Action,ActionErrorResult,@@ -254,6 +255,9 @@ class Agent(raiseexcept AgentException as e:result = ActionErrorResult.from_exception(e)+ logger.warning(+ f"{command_name}({fmt_kwargs(command_args)}) raised an error: {e}"+ )result_tlength = self.llm_provider.count_tokens(str(result), self.llm.name)if result_tlength > self.send_token_limit // 3:diff --git a/autogpts/autogpt/autogpt/app/agent_protocol_server.py b/autogpts/autogpt/autogpt/app/agent_protocol_server.pyindex 1ee6f1efaf..29ab004a26 100644--- a/autogpts/autogpt/autogpt/app/agent_protocol_server.py+++ b/autogpts/autogpt/autogpt/app/agent_protocol_server.py@@ -39,6 +39,7 @@ from autogpt.file_workspace import (FileWorkspaceBackendName,get_workspace,)+from autogpt.logs.utils import fmt_kwargsfrom autogpt.models.action_history import ActionErrorResult, ActionSuccessResultlogger = logging.getLogger(__name__)@@ -428,7 +429,3 @@ class AgentProtocolServer:def task_agent_id(task_id: str | int) -> str:return f"AutoGPT-{task_id}"---def fmt_kwargs(kwargs: dict) -> str:- return ", ".join(f"{n}={repr(v)}" for n, v in kwargs.items())diff --git a/autogpts/autogpt/autogpt/logs/utils.py b/autogpts/autogpt/autogpt/logs/utils.pyindex 0b92e2967d..d9f39af309 100644--- a/autogpts/autogpt/autogpt/logs/utils.py+++ b/autogpts/autogpt/autogpt/logs/utils.py@@ -3,3 +3,7 @@ import redef remove_color_codes(s: str) -> str:return re.sub(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])", "", s)+++def fmt_kwargs(kwargs: dict) -> str:+ return ", ".join(f"{n}={repr(v)}" for n, v in kwargs.items())