mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-09 08:21:50 +00:00
fix(agent): clear _session_messages in AIAgent.close() (#42123)
close() is the hard teardown for true session boundaries (/new, /reset, session expiry). It already closes the OpenAI client and child agents but left the conversation-history list intact. Mirror the soft-eviction path (_release_evicted_agent_soft clears _session_messages) so a held reference to a closed agent — e.g. a draining background task — doesn't pin tens of MB of tool outputs until the agent object itself is collected.
This commit is contained in:
parent
cb13723f53
commit
5e06c9ffef
1 changed files with 11 additions and 0 deletions
11
run_agent.py
11
run_agent.py
|
|
@ -3087,6 +3087,17 @@ class AIAgent:
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
# 6. Free conversation history. Mirrors _release_evicted_agent_soft's
|
||||
# soft-eviction clear — close() is the hard teardown for true session
|
||||
# boundaries (/new, /reset, session expiry), so the message list won't
|
||||
# be reused. Drops the reference proactively rather than waiting for
|
||||
# the agent object itself to be collected, which matters when a caller
|
||||
# still holds the closed agent (e.g. a draining background task).
|
||||
try:
|
||||
self._session_messages = []
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _hydrate_todo_store(self, history: List[Dict[str, Any]]) -> None:
|
||||
"""
|
||||
Recover todo state from conversation history.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue