From 3ead3401e0b0d1e1059c0b28c183b8ca5b6b3c7b Mon Sep 17 00:00:00 2001 From: teknium1 Date: Mon, 2 Mar 2026 21:31:23 -0800 Subject: [PATCH] fix(mcp): persist updated tools to session log immediately after reload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After /reload-mcp updates self.agent.tools, immediately call _persist_session() so the session JSON file at ~/.hermes/sessions/ reflects the new tools list. Without this, the tools field in the session log would only update on the next conversation turn — if the user quit after reloading, the log would have stale tools. --- cli.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cli.py b/cli.py index 1808d91a..4079d89c 100755 --- a/cli.py +++ b/cli.py @@ -1962,6 +1962,18 @@ class HermesCLI: "role": "user", "content": f"[SYSTEM: MCP servers have been reloaded. {change_detail}{tool_summary}. The tool list for this conversation has been updated accordingly.]", }) + + # Persist session immediately so the session log reflects the + # updated tools list (self.agent.tools was refreshed above). + if self.agent is not None: + try: + self.agent._persist_session( + self.conversation_history, + self.conversation_history, + ) + except Exception: + pass # Best-effort + print(f" ✅ Agent updated — {len(self.agent.tools if self.agent else [])} tool(s) available") except Exception as e: