fix: scope session search handoff recall - #35762
Conversation
94bb88d to
c478951
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused current-chat recall design and the regression coverage.
Problems
- The new scope payload is wired only through the sequential dispatcher (
agent/tool_executor.py:720-730in this PR). Current main’s concurrent path dispatchessession_searchthroughagent/agent_runtime_helpers.py:2260-2278, where onlydbandcurrent_session_idare forwarded; concurrent calls would therefore remain globally scoped. - Current main added exact-title retrieval after this branch.
tools/session_search_tool.py:499-553resolves and appends a title result before the FTS filtering loop. The proposed filtering at this PR’stools/session_search_tool.py:558-565would not constrain a matching title from another chat after salvage. - The storage changes are stale relative to current main:
hermes_state.py:718-725already persists most routing fields, and session initialization has moved intoagent/agent_init.py.
Suggested changes
- Carry the hidden gateway scope through both execution paths and add a concurrent-dispatch regression.
- Scope exact-title matches as well as FTS, browse, handoff, and scroll paths; add a same-title cross-chat test.
- Adapt persistence changes to the current SessionDB reconciliation and gateway peer APIs.
Automated hermes-sweeper review.
| scope=function_args.get("scope"), | ||
| db=session_db, | ||
| current_session_id=agent.session_id, | ||
| current_source=agent.platform or getattr(agent, "_platform", None), |
There was a problem hiding this comment.
This only covers the sequential executor. Current main’s concurrent path calls agent_runtime_helpers.invoke_tool() and its session_search branch still forwards only db and current_session_id; please thread this same scope payload through that path and add a concurrent-dispatch regression.
| sort: Optional[str], | ||
| current_session_id: str = None, | ||
| *, | ||
| current_scope: Optional[Dict[str, str]] = None, |
There was a problem hiding this comment.
When salvaging onto current main, apply this scope to exact-title results too: current _discover() resolves and appends _title_match_result() before the FTS-row loop, so filtering only FTS hits still exposes a same-title session from another chat.
Summary
session_searchprevious/handoff recall to the current gateway/session boundary when requested.user_id_alt, chat/thread/session key) on session rows so recall filtering can distinguish QQ chats/threads.Verification
git diff --checkpython3 -m pytest tests/tools/test_session_search.py tests/test_hermes_state.py -o addopts='' -q→ 275 passedpython3 scripts/check-windows-footguns.py --allpython3 -m py_compile agent/tool_executor.py gateway/session.py hermes_state.py run_agent.py tools/session_search_tool.py tools/process_registry.pyNotes
NousResearch/mainto avoid the stale fork-main diff pollution that affected PR Support passing morph snapshot id #2.fix/session-search-scope-handoffis preserved; PR Support passing morph snapshot id #2 was closed without deleting it.