From d6b78362102a07276a796075d9de01ad9ac6b604 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sun, 29 Mar 2026 17:49:58 -0700 Subject: [PATCH] fix: update session_log_file during context compression (#3835) When compression creates a child session with a new session_id, session_log_file was still pointing to the old session's JSON file. This caused _save_session_log() to write new data to the wrong file. Closes #3731. Co-authored-by: kelsia14 --- run_agent.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/run_agent.py b/run_agent.py index 66f1ff4c8..52c727f05 100644 --- a/run_agent.py +++ b/run_agent.py @@ -5183,6 +5183,8 @@ class AIAgent: self._session_db.end_session(self.session_id, "compression") old_session_id = self.session_id self.session_id = f"{datetime.now().strftime('%Y%m%d_%H%M%S')}_{uuid.uuid4().hex[:6]}" + # Update session_log_file to point to the new session's JSON file + self.session_log_file = self.logs_dir / f"session_{self.session_id}.json" self._session_db.create_session( session_id=self.session_id, source=self.platform or os.environ.get("HERMES_SESSION_SOURCE", "cli"),