Skip to content

feat(claude-code): full-session retain with document upsert and configurable tags - #695

Merged
nicoloboschi merged 3 commits into
mainfrom
feature/claude-code-plugin-session-doc
Mar 26, 2026
Merged

feat(claude-code): full-session retain with document upsert and configurable tags#695
nicoloboschi merged 3 commits into
mainfrom
feature/claude-code-plugin-session-doc

Conversation

@nicoloboschi

Copy link
Copy Markdown
Collaborator

Summary

  • Full-session retain mode (new default): retains the entire conversation transcript as a single document per session, using session_id as the document_id for upsert semantics. Previously each retain call created a new fragmented document with a timestamp-suffixed ID.
  • Configurable tags (retainTags): list of tags sent with each retain call, with template variable support ({session_id}, {bank_id}, {timestamp}). Default: ["{session_id}"].
  • Configurable metadata (retainMetadata): extra metadata merged with built-in fields, same template support.
  • Legacy chunked mode preserved via retainMode: "chunked" config.

Test plan

  • Existing 16 tests pass
  • New test: full-session mode uses session_id as document_id and includes all messages
  • New test: retainTags resolves template variables correctly
  • New test: retainMetadata merges with built-in metadata and resolves templates
  • Chunked mode test updated to explicitly set retainMode: "chunked"

…configurable tags

Switch default retain behavior from per-turn chunks to full-session upsert.
Each session is now retained as a single document (document_id = session_id)
that gets updated on every Stop event, instead of creating fragmented
documents with timestamp-suffixed IDs.

New config options:
- retainMode: "full-session" (default) or "chunked" (legacy)
- retainTags: list with template variable support ({session_id}, {bank_id}, {timestamp})
- retainMetadata: extra metadata dict merged with built-in fields, supports templates
The turn-count gating was only applied in chunked mode, meaning
full-session mode would re-ingest the entire transcript on every
single Stop event. Now retainEveryNTurns gates both modes.

Also fix test isolation: resolve ~/.hindsight/claude-code.json at
call time (not module load) so HOME override in tests works correctly.
Update tests to use HOME env var override instead of monkeypatching
the removed USER_CONFIG_PATH constant. Add autouse fixture to
TestLoadConfig to isolate all config tests from real user config
and HINDSIGHT_* env vars.
@nicoloboschi
nicoloboschi merged commit 2d31b67 into main Mar 26, 2026
32 of 33 checks passed
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.

1 participant