[Refactor, Fix]: Agent controller state/metrics management (#9012)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Rohit Malhotra
2025-06-16 11:24:13 -04:00
committed by GitHub
parent cbe32a1a12
commit 2fd1fdcd7e
27 changed files with 1404 additions and 667 deletions

View File

@@ -232,8 +232,7 @@ class AgentSession:
if self.event_stream is not None:
self.event_stream.close()
if self.controller is not None:
end_state = self.controller.get_state()
end_state.save_to_session(self.sid, self.file_store, self.user_id)
self.controller.save_state()
await self.controller.close()
if self.runtime is not None:
EXECUTOR.submit(self.runtime.close)
@@ -439,10 +438,12 @@ class AgentSession:
initial_state = self._maybe_restore_state()
controller = AgentController(
sid=self.sid,
user_id=self.user_id,
file_store=self.file_store,
event_stream=self.event_stream,
agent=agent,
max_iterations=int(max_iterations),
max_budget_per_task=max_budget_per_task,
iteration_delta=int(max_iterations),
budget_per_task_delta=max_budget_per_task,
agent_to_llm_config=agent_to_llm_config,
agent_configs=agent_configs,
confirmation_mode=confirmation_mode,