fix: link subagent sessions to parent and hide from session list
Subagent sessions spawned by delegate_task were created with parent_session_id=NULL and source=cli, making them indistinguishable from user sessions in hermes sessions list and /resume. Changes: - delegate_tool.py: pass parent_agent.session_id to child agent - run_agent.py: accept parent_session_id param, pass to create_session - hermes_state.py list_sessions_rich: filter parent_session_id IS NULL by default (opt-in include_children=True for callers that need them) - hermes_state.py delete_session: delete child sessions first (FK) - hermes_state.py prune_sessions: delete children before parents (FK) session_search already handles parent_session_id correctly — child sessions are filtered from recent list and resolved to parent root in full-text search results. Fixes #5122
This commit is contained in:
@@ -530,6 +530,7 @@ class AIAgent:
|
||||
skip_context_files: bool = False,
|
||||
skip_memory: bool = False,
|
||||
session_db=None,
|
||||
parent_session_id: str = None,
|
||||
iteration_budget: "IterationBudget" = None,
|
||||
fallback_model: Dict[str, Any] = None,
|
||||
credential_pool=None,
|
||||
@@ -1025,6 +1026,7 @@ class AIAgent:
|
||||
|
||||
# SQLite session store (optional -- provided by CLI or gateway)
|
||||
self._session_db = session_db
|
||||
self._parent_session_id = parent_session_id
|
||||
self._last_flushed_db_idx = 0 # tracks DB-write cursor to prevent duplicate writes
|
||||
if self._session_db:
|
||||
try:
|
||||
@@ -1038,6 +1040,7 @@ class AIAgent:
|
||||
"max_tokens": max_tokens,
|
||||
},
|
||||
user_id=None,
|
||||
parent_session_id=self._parent_session_id,
|
||||
)
|
||||
except Exception as e:
|
||||
# Transient SQLite lock contention (e.g. CLI and gateway writing
|
||||
|
||||
Reference in New Issue
Block a user