Skip to content

hermes chat --source <name> does not persist — sessions always recorded as source=cli #45107

Open

Description

@jffuree

Summary

Passing --source <name> to hermes chat has no effect on what gets stored in
state.db: the session's source column is always cli. This breaks any
workflow that needs to distinguish tool-driven sessions from real user
sessions via SQL.

Environment

  • hermes-agent v0.16.0 (rolling main), macOS 15 (Apple Silicon)
  • Model: GPT-5.5 via openai-codex provider

Reproduction

hermes chat --source distiller -q "Say OK and nothing else."
sqlite3 ~/.hermes/state.db \
  "SELECT id, source FROM sessions ORDER BY created_at DESC LIMIT 1;"

Expected: source = 'distiller'
Actual: source = 'cli'

Impact

We run a nightly batch "distiller" that reads conversation transcripts out of
state.db and extracts durable facts. To avoid re-ingesting its own
prompts (a feedback loop), it filters WHERE s.source IS NOT 'distiller' —
but since --source never sticks, the filter is useless and every batch run
pollutes the next run's input set. We currently work around it with a
prompt-prefix guard (skip sessions whose first user message starts with a
known marker), but that's fragile, and the mislabeled sessions still
accumulate in state.db.

Any other programmatic consumer of hermes chat (cron jobs, CI, agent
pipelines) has the same problem: no reliable way to tag and later exclude
machine-generated sessions.

Notes

--source is accepted without error, so this looks like the value is parsed
but dropped before session creation rather than an unsupported flag.

Activity

  1. added
    type/bugSomething isn't working
    comp/cliCLI entry point, hermes_cli/, setup wizard
    P3Low — cosmetic, nice to have
    on Jun 12, 2026
  2. GottZ commented on Jul 28, 2026

    @GottZ

    This was generated by AI during triage.

    Summary

    Three closed PRs address #45107 by making the explicit HERMES_SESSION_SOURCE override the default platform during session creation. #45126 additionally applies that precedence to compression-rotated sessions and memory metadata, #45130 limits the change to the reported interactive-session path, and #45157 adds relaunch inheritance that conflicts with the documented current relaunch contract.

    Related pull requests

    Duplicates

    #45126, #45130, and #45157 duplicate the core _ensure_db_session() precedence fix; #45130 is the narrowest duplicate, while #45126 adds related persistence paths and #45157 adds a distinct, rejected relaunch-inheritance change.

    Suggested consolidation

    Do not reopen or merge these closed PRs: use verify-selected #45126 as the best-fix/reference implementation for #45107, while respecting the contributor duplicate review that points to earlier #40866 and the later confirmation that the core behavior is already on main. #45130 can remain closed as a narrower duplicate, and #45157 can remain closed because its shared fix is redundant and its extra relaunch behavior conflicts with the documented repository design.

    Complex graph

    flowchart LR
        classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
        classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
        classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
        classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
        classDef best stroke-width:3px,stroke:#b45309
        classDef target stroke-width:3px,stroke:#4338ca
        I45107(["issue #45107 (open)"])
        subgraph Dup45126 ["PRs duplicating each other"]
            P45126["PR #45126 (closed)"]
            P45130["PR #45130 (closed)"]
            P45157["PR #45157 (closed)"]
        end
        P45126 -->|best fix| I45107
        P45130 -->|fixes| I45107
        P45157 -->|fixes| I45107
        class I45107 open
        class I45107 target
        class P45126 closed
        class P45130 closed
        class P45157 closed
        class P45126 best
        click I45107 "https://github.com/NousResearch/hermes-agent/issues/45107"
        click P45126 "https://github.com/NousResearch/hermes-agent/pull/45126"
        click P45130 "https://github.com/NousResearch/hermes-agent/pull/45130"
        click P45157 "https://github.com/NousResearch/hermes-agent/pull/45157"
    
    Loading

    Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed or no verify verdict yet (state tag in the node label).

    Cross-PR triage: Reviewed 3 pull requests and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 16 kB of PR diffs, 8 kB of issue/PR text, 2 kB of discussion (5 comments), 7 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

  3. BrendanJMurphy commented on Sep 17, 2026

    @BrendanJMurphy

    Fixed on main. run_agent.py:59-72 _session_source_for_agent() now reads HERMES_SESSION_SOURCE first and returns source or platform or "cli", and _ensure_db_session() uses it when creating the row (run_agent.py:335-359), so --source <name> is what gets persisted.

    The change came in a7983d5 (2026-06-19, "fix(dashboard): hide sidecar sessions from history", #49269) — it replaced the old self.platform or os.environ.get(...) precedence that always won for platform. Not from the PRs referenced earlier in this thread. A later commit, 0010273 (2026-09-16), completes the -q interaction so an explicit --source survives the one-shot relabel.

    One sibling still carries the old pattern: agent/background_review.py:700 does agent.platform or os.environ.get("HERMES_SESSION_SOURCE", "cli"). Harmless for the CLI path in this report (platform is falsy there), but it will mislabel if platform is ever set — worth a follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havearea/sessionsSession lifecycle, resume, persistence, historycomp/cliCLI entry point, hermes_cli/, setup wizardtype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions