Skip to content

feat(gateway): add role-scoped session search - #47535

Closed
abhibansal-sg wants to merge 1 commit into
NousResearch:mainfrom
abhibansal-sg:feat/session-search-scope
Closed

feat(gateway): add role-scoped session search#47535
abhibansal-sg wants to merge 1 commit into
NousResearch:mainfrom
abhibansal-sg:feat/session-search-scope

Conversation

@abhibansal-sg

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds an optional scope query parameter to the dashboard session-search endpoint
(GET /api/sessions/search) so a caller can restrict matches by message role. It
maps a public scope name onto the db layer's existing role_filter:

  • all (default) — every role, plus direct session-id matches. Byte-identical
    to today's behaviour.
  • messages — user + assistant prose only (excludes tool output).
  • code — tool messages only (command output / file contents / structured results).

Any unrecognised value is treated as all. A non-all scope also drops the
session-id match pass so the result list stays a pure content-scoped result.

Related Issue

N/A

Type of Change

  • ✨ New feature (additive, backward-compatible)

Changes Made

  • hermes_cli/web_server.py: added a scope: str = "all" query param to
    search_sessions; normalise it to a role_filter
    (messages → ["user","assistant"], code → ["tool"], everything else →
    None); skip the session-id pass when a scope is active; pass role_filter to
    search_messages only when a scope is active.
  • tests/hermes_cli/test_web_server_session_search.py: 4 new tests covering the
    default (unchanged) path, both explicit scopes, and graceful fallback for an
    invalid scope.

No db-layer change: SessionDB.search_messages already accepts role_filter
(default None = unchanged). No new env vars, hooks, or registries.

How to Test

  1. scripts/run_tests.sh tests/hermes_cli/test_web_server_session_search.py
  2. Manually against a running dashboard:
    • GET /api/sessions/search?q=docker and ?q=docker&scope=all → identical results.
    • ?q=docker&scope=messages → user/assistant hits only.
    • ?q=docker&scope=code → tool-message hits only.
    • ?q=docker&scope=bogus → behaves exactly like all (no error).

Checklist

  • Default (scope=all / omitted) is byte-identical to current stock
  • One logical, additive change; no new env vars / hooks / observers / registries
  • Focused tests added (default-equivalence, explicit-scope, invalid-scope fallback)
  • scripts/run_tests.sh green for the changed file + surrounding suites
  • check-windows-footguns.py clean
  • Conventional Commit, imperative, no trailing period

Add an optional `scope` query parameter to the dashboard session-search
endpoint (`GET /api/sessions/search`). It maps a public scope name onto the
db layer's existing `role_filter` so callers can narrow results by message
role:

  - all      (default): every role + direct session-id matches
  - messages: user + assistant prose only
  - code:     tool messages only

The default `scope=all` is byte-identical to the historical behaviour: the
session-id pass still runs and `search_messages` is called with the exact same
kwargs as before (no `role_filter`). Unknown scopes fall back to `all`.
SessionDB.search_messages already accepts `role_filter` (default None), so no
db-layer change is needed.
@alt-glitch alt-glitch added type/feature New feature or request comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have labels Jun 17, 2026
@alt-glitch alt-glitch added comp/dashboard Web dashboard / control panel UI (dashboard/, landing) and removed comp/gateway Gateway runner, session dispatch, delivery labels Jun 26, 2026
@GodsBoy GodsBoy mentioned this pull request Jul 3, 2026
19 tasks
@abhibansal-sg
abhibansal-sg deleted the feat/session-search-scope branch July 15, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/dashboard Web dashboard / control panel UI (dashboard/, landing) P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants