feat(gateway): add role-scoped session search - #47535
Closed
abhibansal-sg wants to merge 1 commit into
Closed
Conversation
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.
19 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds an optional
scopequery parameter to the dashboard session-search endpoint(
GET /api/sessions/search) so a caller can restrict matches by message role. Itmaps a public scope name onto the db layer's existing
role_filter:all(default) — every role, plus direct session-id matches. Byte-identicalto 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-allscope also drops thesession-id match pass so the result list stays a pure content-scoped result.
Related Issue
N/A
Type of Change
Changes Made
hermes_cli/web_server.py: added ascope: str = "all"query param tosearch_sessions; normalise it to arole_filter(
messages → ["user","assistant"],code → ["tool"], everything else →None); skip the session-id pass when a scope is active; passrole_filtertosearch_messagesonly when a scope is active.tests/hermes_cli/test_web_server_session_search.py: 4 new tests covering thedefault (unchanged) path, both explicit scopes, and graceful fallback for an
invalid scope.
No db-layer change:
SessionDB.search_messagesalready acceptsrole_filter(default
None= unchanged). No new env vars, hooks, or registries.How to Test
scripts/run_tests.sh tests/hermes_cli/test_web_server_session_search.pyGET /api/sessions/search?q=dockerand?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 likeall(no error).Checklist
scope=all/ omitted) is byte-identical to current stockscripts/run_tests.shgreen for the changed file + surrounding suitescheck-windows-footguns.pyclean