From cebd48081885b3b49947510759b6c3478bf334ba Mon Sep 17 00:00:00 2001 From: yoniebans Date: Wed, 20 May 2026 09:19:13 +0200 Subject: [PATCH] refactor(session-log): drop branch/compress re-point of session_log_file The attribute no longer exists; nothing to re-point. --- agent/conversation_compression.py | 2 -- cli.py | 6 ------ tests/cli/test_branch_command.py | 24 ------------------------ 3 files changed, 32 deletions(-) diff --git a/agent/conversation_compression.py b/agent/conversation_compression.py index a3a9ba1d6fb..cd1b133fa4a 100644 --- a/agent/conversation_compression.py +++ b/agent/conversation_compression.py @@ -387,8 +387,6 @@ def compress_context( _SESSION_ID.set(agent.session_id) except Exception: pass - # Update session_log_file to point to the new session's JSON file - agent.session_log_file = agent.logs_dir / f"session_{agent.session_id}.json" agent._session_db_created = False agent._session_db.create_session( session_id=agent.session_id, diff --git a/cli.py b/cli.py index 033a60077f0..9e1b0a628e5 100644 --- a/cli.py +++ b/cli.py @@ -6501,12 +6501,6 @@ class HermesCLI: if self.agent: self.agent.session_id = new_session_id self.agent.session_start = now - # Redirect the JSON session log to the new branch session file so - # messages written after branching land in the correct file. - if hasattr(self.agent, "session_log_file") and hasattr(self.agent, "logs_dir"): - self.agent.session_log_file = ( - self.agent.logs_dir / f"session_{new_session_id}.json" - ) self.agent.reset_session_state() if hasattr(self.agent, "_last_flushed_db_idx"): self.agent._last_flushed_db_idx = len(self.conversation_history) diff --git a/tests/cli/test_branch_command.py b/tests/cli/test_branch_command.py index 5e78815b8f2..409ab295fc0 100644 --- a/tests/cli/test_branch_command.py +++ b/tests/cli/test_branch_command.py @@ -160,30 +160,6 @@ class TestBranchCommandCLI: assert agent.reset_session_state.called assert agent._last_flushed_db_idx == 4 # len(conversation_history) - def test_branch_updates_agent_session_log_file(self, cli_instance, session_db, tmp_path): - """Branching must redirect the agent's session_log_file to the new session's path.""" - from cli import HermesCLI - from pathlib import Path - - logs_dir = tmp_path / "sessions" - logs_dir.mkdir() - - agent = MagicMock() - agent._last_flushed_db_idx = 0 - agent.logs_dir = logs_dir - agent.session_log_file = logs_dir / f"session_{cli_instance.session_id}.json" - cli_instance.agent = agent - - old_log_file = agent.session_log_file - HermesCLI._handle_branch_command(cli_instance, "/branch") - - new_session_id = cli_instance.session_id - expected_log = logs_dir / f"session_{new_session_id}.json" - assert agent.session_log_file == expected_log, ( - "session_log_file must point to the branch session, not the original" - ) - assert agent.session_log_file != old_log_file - def test_branch_sets_resumed_flag(self, cli_instance, session_db): """Branch should set _resumed=True to prevent auto-title generation.""" from cli import HermesCLI