Selaa lähdekoodia

[Fix] Metrics should be updated when agent reaches max iterations. (#3549)

Raj Maheshwari 1 vuosi sitten
vanhempi
sitoutus
11d8d05b1a

+ 5 - 1
evaluation/aider_bench/run_infer.py

@@ -120,11 +120,15 @@ async def complete_runtime(
     obs = await runtime.run_action(action)
     logger.info(obs, extra={'msg_type': 'OBSERVATION'})
 
+    exit_code = 1
+    if isinstance(obs, CmdOutputObservation):
+        exit_code = obs.exit_code
+
     logger.info(f"{'-' * 50} END Runtime Completion Fn {'-' * 50}")
 
     return {
         'test_output': obs.content,
-        'exit_code': obs.exit_code,
+        'exit_code': exit_code,
     }
 
 

+ 2 - 0
openhands/controller/agent_controller.py

@@ -220,6 +220,8 @@ class AgentController:
                 logger.info(event, extra={'msg_type': 'OBSERVATION'})
             elif isinstance(event, ErrorObservation):
                 logger.info(event, extra={'msg_type': 'OBSERVATION'})
+                if self.state.agent_state == AgentState.ERROR:
+                    self.state.metrics.merge(self.state.local_metrics)
 
     def reset_task(self):
         """Resets the agent's task."""