mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
less debug info when errors happen (#1233)
* less debug info when errors happen * add another traceback * better prompt debugs * remove unuse arg
This commit is contained in:
parent
0a59d46ca3
commit
d61fdb8bba
@ -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:
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user