Skip to content

fix(gateway): resume numbered session search results - #60138

Open
GodsBoy wants to merge 3 commits into
NousResearch:mainfrom
GodsBoy:fix/session-search-numbered-resume
Open

fix(gateway): resume numbered session search results#60138
GodsBoy wants to merge 3 commits into
NousResearch:mainfrom
GodsBoy:fix/session-search-numbered-resume

Conversation

@GodsBoy

@GodsBoy GodsBoy commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Gateway session numbers now refer to the latest numbered session list shown in that same chat. After /sessions search <query> returns old matching sessions, /resume <number> resumes the row the user picked instead of re-querying the unrelated default recent /resume list.

The remembered rows are scoped by gateway session key, bounded to the 10 displayed choices, and stored only after the existing visibility filtering. Final resume authorization is unchanged: the selected id still flows through continuation resolution, Matrix room checks, owner checks, and the existing switch path.

Related Issue

Fixes #60136

Related: #57685, #57595

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Security fix
  • Documentation update
  • Tests (adding or improving test coverage)
  • Refactor (no behavior change)
  • New skill (bundled or hub)

Changes Made

  • gateway/slash_commands.py: remember the latest numbered gateway session list per session key and resolve numeric /resume against it before falling back to the old bare /resume behavior.
  • hermes_cli/session_listing.py: clarify the gateway listing footer so numbers are documented as coming from the latest session list, not only from /resume.
  • tests/gateway/test_resume_command.py: cover numbered resume from /sessions search, out-of-range search choices, stale no-result searches, and cross-chat isolation.

How to Test

  1. In a gateway chat with old matching sessions outside the default recent list, run /sessions search <query>.
  2. Send /resume <number> using a number from that search result.
  3. Hermes should resume the session shown at that number.

Local verification:

scripts/run_tests.sh tests/gateway/test_resume_command.py tests/hermes_cli/test_session_listing.py -q
/root/clawd/repos/hermes/.venv/bin/python -m py_compile gateway/slash_commands.py hermes_cli/session_listing.py tests/gateway/test_resume_command.py

Manual validation:

  • Patched the VPS install and confirmed in a Telegram bound topic that /sessions search <query> followed by /resume <returned number> resumes the selected old session.
  • I did not restart the gateway again after that manual validation.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Ubuntu Linux, Python 3.11.14, Telegram gateway

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior or N/A

Screenshots / Logs

Technical breakdown of the numbered session resume fix:

Technical breakdown of numbered session resume fix

Sample of issue:

image

Manual Telegram validation above exercised the reported flow end to end.

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery comp/cli CLI entry point, hermes_cli/, setup wizard sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state P2 Medium — degraded but workaround exists labels Jul 7, 2026
@GodsBoy
GodsBoy force-pushed the fix/session-search-numbered-resume branch from a631d1b to 2983904 Compare July 11, 2026 18:52

@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 tracing the search/list and numeric-resume mismatch; current main still has that mismatch in gateway/slash_commands.py:3616-3629, so the fix direction is valid.

Problems

  • In the PR head, bare /resume returns for an empty titled list at gateway/slash_commands.py:3605-3608 before it reaches the new cache write at :3609. A previous /sessions search mapping remains armed and is then used at :3629-3646, although the latest numbered-list command showed no choices.
  • _latest_gateway_session_choices is a plain unbounded dict at gateway/slash_commands.py:108-112. Main caps analogous long-lived session-source state at gateway/run.py:2975-2981 and trims it at :10863-10868.

Suggested changes

  • Clear the remembered entry before each empty-list return and add the bare-/resume stale-selection regression case.
  • Bound remembered session-key entries with an LRU or existing lifecycle cleanup, with coverage for eviction.

Automated hermes-sweeper review.

Comment thread gateway/slash_commands.py
Comment thread gateway/slash_commands.py
@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
Clear stale choices after empty resume lists and retain numbered mappings in a capped LRU cache.
@GodsBoy

GodsBoy commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Clear stale numbered choices after an empty bare /resume, and bound remembered session keys.

Addressed in 8212691. Empty resume listings now disarm earlier search choices, and the mapping is a capped 512-entry LRU with eviction coverage. The focused resume suite passes: 58 passed.

@GodsBoy

GodsBoy commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

The implementation, test slices, e2e, lint, type, docs, JS/TS, supply-chain, and Docker checks all pass. The only failing gate is Python lints / CI-sensitive file review, which requires a maintainer to apply the ci-reviewed label.

@GodsBoy

GodsBoy commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Current head merges cleanly with current main. The implementation, tests, lint, type, docs, supply-chain, and Docker checks pass; the only remaining required gate is the maintainer-controlled ci-reviewed label. @teknium1, please check, apply the label, and merge if you are happy with it.

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/cli CLI entry point, hermes_cli/, setup wizard 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-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/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway /resume <number> ignores /sessions search result numbering

3 participants