Skip to content

πŸ™Œ OpenHands: AI-Driven Development

less debug info when errors happen (#1233)

Robert Brennand61fdb8bba9e
diff --git a/opendevin/controller/action_manager.py b/opendevin/controller/action_manager.py
index 53105733b2..d6b694c7e3 100644
--- a/opendevin/controller/action_manager.py
+++ b/opendevin/controller/action_manager.py
@@ -50,7 +50,7 @@ class ActionManager:
except Exception as e:
observation = AgentErrorObservation(str(e))
logger.error(e)
- traceback.print_exc()
+ logger.debug(traceback.format_exc())
return observation
def run_command(self, command: str, background=False) -> CmdOutputObservation:
diff --git a/opendevin/controller/agent_controller.py b/opendevin/controller/agent_controller.py
index eb7e6d4ac9..01a6e31f64 100644
--- a/opendevin/controller/agent_controller.py
+++ b/opendevin/controller/agent_controller.py
@@ -1,5 +1,6 @@
import asyncio
import time
+import traceback
from typing import Callable, List
from litellm.exceptions import APIConnectionError
@@ -169,12 +170,13 @@ class AgentController:
observation: Observation = NullObservation('')
try:
action = self.agent.step(self.state)
+ logger.info(action, extra={'msg_type': 'ACTION'})
if action is None:
raise AgentNoActionError()
- logger.info(action, extra={'msg_type': 'ACTION'})
except Exception as e:
observation = AgentErrorObservation(str(e))
logger.error(e)
+ logger.debug(traceback.format_exc())
if isinstance(e, APIConnectionError):
time.sleep(3)
diff --git a/opendevin/llm/llm.py b/opendevin/llm/llm.py
index aab9f49312..105fb2838a 100644
--- a/opendevin/llm/llm.py
+++ b/opendevin/llm/llm.py
@@ -46,7 +46,10 @@ class LLM:
messages = kwargs['messages']
else:
messages = args[1]
- llm_prompt_logger.debug(messages)
+ debug_message = ''
+ for message in messages:
+ debug_message += '\n\n----------\n\n' + message['content']
+ llm_prompt_logger.debug(debug_message)
resp = completion_unwrapped(*args, **kwargs)
message_back = resp['choices'][0]['message']['content']
llm_response_logger.debug(message_back)
diff --git a/opendevin/main.py b/opendevin/main.py
index 3fecc801e7..3609b098db 100644
--- a/opendevin/main.py
+++ b/opendevin/main.py
@@ -26,12 +26,6 @@ def parse_arguments():
"""Parse command-line arguments."""
parser = argparse.ArgumentParser(
description='Run an agent with a specific task')
- parser.add_argument(
- '-d',
- '--directory',
- type=str,
- help='The working directory for the agent',
- )
parser.add_argument(
'-t', '--task', type=str, default='', help='The task for the agent to perform'
)
@@ -89,7 +83,7 @@ async def main():
'No task provided. Please specify a task through -t, -f.')
print(
- f'Running agent {args.agent_cls} (model: {args.model_name}, directory: {args.directory}) with task: "{task}"'
+ f'Running agent {args.agent_cls} (model: {args.model_name}) with task: "{task}"'
)
llm = LLM(args.model_name)
AgentCls: Type[Agent] = Agent.get_cls(args.agent_cls)