π OpenHands: AI-Driven Development
[eval,fix]: metrics get carried across eval instances (#3072)
Xingyao Wang41a8bb3cf14f
diff --git a/opendevin/controller/agent.py b/opendevin/controller/agent.pyindex bb5b6b9439..4899e6a978 100644--- a/opendevin/controller/agent.py+++ b/opendevin/controller/agent.py@@ -57,6 +57,9 @@ class Agent(ABC):# TODO clear historyself._complete = False+ if self.llm:+ self.llm.reset()+@propertydef name(self):return self.__class__.__name__diff --git a/opendevin/controller/state/state.py b/opendevin/controller/state/state.pyindex f0ae54edfb..2c25f916f3 100644--- a/opendevin/controller/state/state.py+++ b/opendevin/controller/state/state.py@@ -97,9 +97,9 @@ class State:resume_state: AgentState | None = Nonetraffic_control_state: TrafficControlState = TrafficControlState.NORMAL# global metrics for the current task- metrics: Metrics = Metrics()+ metrics: Metrics = field(default_factory=Metrics)# local metrics for the current subtask- local_metrics: Metrics = Metrics()+ local_metrics: Metrics = field(default_factory=Metrics)# root agent has level 0, and every delegate increases the level by onedelegate_level: int = 0# start_id and end_id track the range of events in historydiff --git a/opendevin/llm/llm.py b/opendevin/llm/llm.pyindex 6fb29a560d..aff76421f3 100644--- a/opendevin/llm/llm.py+++ b/opendevin/llm/llm.py@@ -252,3 +252,6 @@ class LLM:def __repr__(self):return str(self)++ def reset(self):+ self.metrics = Metrics()