Skip to content

Commit cfdc2cc

Browse files
committed
Fail agent runs with not-normal exit status/exception
1 parent 0fca875 commit cfdc2cc

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

codeclash/agents/minisweagent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@ def run(self):
6060
)
6161
exit_status = None
6262
result = None
63+
exc_message = None
6364
try:
6465
exit_status, result = self.agent.run(task="", **self.game_context.to_template_vars())
6566
except Exception as e:
6667
exit_status = str(e)
6768
exc_message = traceback.format_exc()
6869
result = exc_message
69-
print(exc_message)
70+
self.logger.critical(exc_message)
7071
finally:
7172
traj_path = (
7273
self.game_context.log_local
@@ -91,3 +92,5 @@ def run(self):
9192
"cost": self.agent.model.cost,
9293
"api_calls": self.agent.model.n_calls,
9394
}
95+
if exit_status.lower().strip() not in ["", "submitted", "limitsexceeded"] and exc_message is not None:
96+
raise RuntimeError(f"Agent {self.name} failed with exit status: {exit_status} and exception: {exc_message}")

0 commit comments

Comments
 (0)