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

This commit is contained in:
Raj Maheshwari
2024-08-23 07:58:16 +05:30
committed by GitHub
parent 9642f8d4be
commit 11d8d05b1a
2 changed files with 7 additions and 1 deletions

View File

@@ -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,
}

View File

@@ -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."""