fix(mcp): persist updated tools to session log immediately after reload
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.
This commit is contained in:
parent
eec31b0089
commit
3ead3401e0
1 changed files with 12 additions and 0 deletions
12
cli.py
12
cli.py
|
|
@ -1962,6 +1962,18 @@ class HermesCLI:
|
||||||
"role": "user",
|
"role": "user",
|
||||||
"content": f"[SYSTEM: MCP servers have been reloaded. {change_detail}{tool_summary}. The tool list for this conversation has been updated accordingly.]",
|
"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")
|
print(f" ✅ Agent updated — {len(self.agent.tools if self.agent else [])} tool(s) available")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue