add error handling for action running (#212)

This commit is contained in:
Robert Brennan
2024-03-26 16:42:27 -04:00
committed by GitHub
parent 9ab15b3287
commit 93656f3bb3

View File

@@ -101,7 +101,12 @@ class AgentController:
action = action_cls(**_kwargs)
print(action, flush=True)
if action.executable:
observation = action.run(self)
try:
observation = action.run(self)
except Exception as e:
observation = AgentErrorObservation(str(e))
print_with_indent("\nACTION RUN ERROR:\n%s" % observation)
traceback.print_exc()
if not isinstance(observation, NullObservation):
print_with_indent("\nOBSERVATION:\n%s" % observation)