Skip to content

feat(sessions): add --source flag for third-party session isolation#3208

Closed
HenkDz wants to merge 1 commit intoNousResearch:mainfrom
HenkDz:feat/session-source-tag
Closed

feat(sessions): add --source flag for third-party session isolation#3208
HenkDz wants to merge 1 commit intoNousResearch:mainfrom
HenkDz:feat/session-source-tag

Conversation

@HenkDz
Copy link
Copy Markdown
Contributor

@HenkDz HenkDz commented Mar 26, 2026

Problem

When third-party tools (like Paperclip orchestrator) spawn hermes chat as a subprocess, their agent sessions pollute the user's CLI session history, hermes sessions list, hermes sessions browse, and session_search results.

Solution

Add a --source <tag> flag to hermes chat that tags sessions with a custom source identifier. Sessions tagged with source=tool are filtered out from user-facing session lists and search by default.

Changes

  • hermes chat --source <tag>: New CLI flag (also settable via HERMES_SESSION_SOURCE env var, same pattern as --yolo)
  • hermes_state.py: Added exclude_sources parameter to list_sessions_rich() and search_messages()
  • session_search_tool.py: Added _HIDDEN_SESSION_SOURCES constant; recent sessions and FTS5 search exclude source=tool by default
  • hermes_cli/main.py: sessions list and sessions browse exclude tool sessions by default
  • cli.py + run_agent.py: Read HERMES_SESSION_SOURCE env var, falling back to "cli"

Usage for third-party adapters

# Option 1: CLI flag
hermes chat -q "..." --source tool -Q

# Option 2: Environment variable
HERMES_SESSION_SOURCE=tool hermes chat -q "..."

Backwards compatible

  • Default behavior unchanged (source defaults to "cli")
  • Filtering only hides source=tool sessions which don't exist yet
  • Users can still see tool sessions with hermes sessions list --source tool

Context

Companion PR: hermes-paperclip-adapter will pass --source tool when spawning Hermes.

…\nWhen third-party tools spawn Hermes as a subprocess, their sessions\npollute the user session history and search results.\n\nThis adds:\n\n- `hermes chat --source <tag>` CLI flag (also via HERMES_SESSION_SOURCE env var)\n- `exclude_sources` parameter on list_sessions_rich() and search_messages()\n- Sessions with source=tool are hidden from sessions list/browse/search by default\n\nThird-party adapters should pass --source tool to keep agent sessions separate.
teknium1 pushed a commit that referenced this pull request Mar 26, 2026
When third-party tools (Paperclip orchestrator, etc.) spawn hermes chat
as a subprocess, their sessions pollute user session history and search.

- hermes chat --source <tag> (also HERMES_SESSION_SOURCE env var)
- exclude_sources parameter on list_sessions_rich() and search_messages()
- Sessions with source=tool hidden from sessions list/browse/search
- Third-party adapters pass --source tool to isolate agent sessions

Cherry-picked from PR #3208 by HenkDz.
teknium1 added a commit that referenced this pull request Mar 26, 2026
…3255)

When third-party tools (Paperclip orchestrator, etc.) spawn hermes chat
as a subprocess, their sessions pollute user session history and search.

- hermes chat --source <tag> (also HERMES_SESSION_SOURCE env var)
- exclude_sources parameter on list_sessions_rich() and search_messages()
- Sessions with source=tool hidden from sessions list/browse/search
- Third-party adapters pass --source tool to isolate agent sessions

Cherry-picked from PR #3208 by HenkDz.

Co-authored-by: Henkey <noonou7@gmail.com>
@teknium1
Copy link
Copy Markdown
Contributor

Merged via PR #3255. Your commit was cherry-picked onto current main with authorship preserved. Two small bugs were fixed on top (source/exclude_sources SQL conflict and getattr guard for non-list subcommands) and 9 tests added. Thanks for the contribution!

@teknium1 teknium1 closed this Mar 26, 2026
StreamOfRon pushed a commit to StreamOfRon/hermes-agent that referenced this pull request Mar 29, 2026
…ousResearch#3255)

When third-party tools (Paperclip orchestrator, etc.) spawn hermes chat
as a subprocess, their sessions pollute user session history and search.

- hermes chat --source <tag> (also HERMES_SESSION_SOURCE env var)
- exclude_sources parameter on list_sessions_rich() and search_messages()
- Sessions with source=tool hidden from sessions list/browse/search
- Third-party adapters pass --source tool to isolate agent sessions

Cherry-picked from PR NousResearch#3208 by HenkDz.

Co-authored-by: Henkey <noonou7@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants