Skip to content

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

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-64c3ceb2
Mar 26, 2026
Merged

feat(sessions): add --source flag for third-party session isolation#3255
teknium1 merged 1 commit intomainfrom
hermes/hermes-64c3ceb2

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

Salvage of PR #3208 by @HenkDz (authorship preserved).

When third-party orchestrators like Paperclip 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.

Changes

  • hermes chat --source <tag>: New CLI flag (also HERMES_SESSION_SOURCE env var)
  • hermes_state.py: exclude_sources parameter on list_sessions_rich() and search_messages()
  • session_search_tool.py: _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

Follow-up fixes

  • Bug fix: Original PR had a conflict where --source tool + exclude_sources=["tool"] produced contradictory SQL returning zero results. Fixed by skipping exclusion when --source is explicitly provided.
  • Bug fix: getattr guard for args.source — not all session subcommands (delete, prune) define this attribute.
  • Tests: 9 new tests covering exclude_sources on both DB methods and the _HIDDEN_SESSION_SOURCES constant.

Usage

# Third-party adapters
hermes chat -q "..." --source tool -Q
HERMES_SESSION_SOURCE=tool hermes chat -q "..."

# Users can still see tool sessions explicitly
hermes sessions list --source tool

6232 tests pass.

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 teknium1 merged commit db241ae into main Mar 26, 2026
3 of 4 checks passed
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