Skip to content

fix(hindsight): scope document_id per process + optional bank_id_template#15079

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-d09f3422
Apr 24, 2026
Merged

fix(hindsight): scope document_id per process + optional bank_id_template#15079
teknium1 merged 2 commits into
mainfrom
hermes/hermes-d09f3422

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of PR #6654 (@nicoloboschi) onto current main.

Resolves cherry-pick conflicts in plugins/memory/hindsight/init.py:

  • retain-batch log line: keep HEAD's self._run_sync() call (preserves timeout wiring from PR feat(hindsight): add configurable HINDSIGHT_TIMEOUT env var #13067) and adopt PR's self._document_id log field (scope fix is the point of the PR)
  • Helper function block around line 262: keep both sides — HEAD's embedded-profile helpers and the PR's bank_id_template helpers coexist

Authorship preserved on both feature commits.

Closes #6602, closes #6654

…te (#6602)

Reusing session_id as document_id caused data loss on /resume: when
the session is loaded again, _session_turns starts empty and the next
retain replaces the entire previously stored content.

Now each process lifecycle gets its own document_id formed as
{session_id}-{startup_timestamp}, so:
- Same session, same process: turns accumulate into one document (existing behavior)
- Resume (new process, same session): writes a new document, old one preserved
- Forks: child process gets its own document; parent's doc is untouched

Also adds session lineage tags so all processes for the same session
(or its parent) can still be filtered together via recall:
- session:<session_id> on every retain
- parent:<parent_session_id> when initialized with parent_session_id

Closes #6602
…anks

Adds an optional bank_id_template config that derives the bank name at
initialize() time from runtime context. Existing users with a static
bank_id keep the current behavior (template is empty by default).

Supported placeholders:
  {profile}   — active Hermes profile (agent_identity kwarg)
  {workspace} — Hermes workspace (agent_workspace kwarg)
  {platform}  — cli, telegram, discord, etc.
  {user}      — platform user id (gateway sessions)
  {session}   — session id

Unsafe characters in placeholder values are sanitized, and empty
placeholders collapse cleanly (e.g. "hermes-{user}" with no user
becomes "hermes"). If the template renders empty, the static bank_id
is used as a fallback.

Common uses:
  bank_id_template: hermes-{profile}            # isolate per Hermes profile
  bank_id_template: {workspace}-{profile}       # workspace + profile scoping
  bank_id_template: hermes-{user}               # per-user banks for gateway
@teknium1 teknium1 merged commit edff2fb into main Apr 24, 2026
10 of 11 checks passed
@teknium1 teknium1 deleted the hermes/hermes-d09f3422 branch April 24, 2026 10:38
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers labels Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P2 Medium — degraded but workaround exists tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Hindsight memory overwrites/loses old session data on /resume

3 participants