Skip to content

fix: scope session search handoff recall - #35762

Open
a249169329-cpu wants to merge 2 commits into
NousResearch:mainfrom
a249169329-cpu:fix/session-search-scope-handoff-clean
Open

fix: scope session search handoff recall#35762
a249169329-cpu wants to merge 2 commits into
NousResearch:mainfrom
a249169329-cpu:fix/session-search-scope-handoff-clean

Conversation

@a249169329-cpu

Copy link
Copy Markdown

Summary

  • Scope session_search previous/handoff recall to the current gateway/session boundary when requested.
  • Persist gateway identity metadata (user_id_alt, chat/thread/session key) on session rows so recall filtering can distinguish QQ chats/threads.
  • Add regression coverage for current-scope handoff/previous recall and cross-chat isolation.

Verification

  • git diff --check
  • python3 -m pytest tests/tools/test_session_search.py tests/test_hermes_state.py -o addopts='' -q → 275 passed
  • Expanded session/gateway/compression suite → 487 passed
  • python3 scripts/check-windows-footguns.py --all
  • python3 -m py_compile agent/tool_executor.py gateway/session.py hermes_state.py run_agent.py tools/session_search_tool.py tools/process_registry.py

Notes

@a249169329-cpu
a249169329-cpu force-pushed the fix/session-search-scope-handoff-clean branch from 94bb88d to c478951 Compare May 31, 2026 07:28
@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery labels May 31, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-730 in this PR). Current main’s concurrent path dispatches session_search through agent/agent_runtime_helpers.py:2260-2278, where only db and current_session_id are forwarded; concurrent calls would therefore remain globally scoped.
  • Current main added exact-title retrieval after this branch. tools/session_search_tool.py:499-553 resolves and appends a title result before the FTS filtering loop. The proposed filtering at this PR’s tools/session_search_tool.py:558-565 would not constrain a matching title from another chat after salvage.
  • The storage changes are stale relative to current main: hermes_state.py:718-725 already persists most routing fields, and session initialization has moved into agent/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.

Comment thread agent/tool_executor.py
scope=function_args.get("scope"),
db=session_db,
current_session_id=agent.session_id,
current_source=agent.platform or getattr(agent, "_platform", None),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 13, 2026
@teknium1 teknium1 added the area/sessions Session lifecycle, resume, persistence, history label Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants