Skip to content

claude-code: skill bodies and harness-injected blocks are retained as user conversation #3023

Description

@runbgp

Problem

The Claude Code integration retains content the harness injects into user turns as if the user had written it. Two cases:

  1. Skill bodies. When a skill is invoked, Claude Code records the full SKILL.md as an ordinary user message beginning Base directory for this skill: <path>. Auto-retain sends it to extraction.
  2. <system-reminder> / <task-notification> blocks. strip_memory_tags() removes Hindsight's own <hindsight_memories> / <relevant_memories> blocks, but nothing removes the harness's.

This is the same class of bug as #1345 (Codex retaining AGENTS.md startup messages), fixed in #1346. The Codex path now has is_synthetic_codex_user_message(); the Claude Code path has no equivalent.

Steps to Reproduce

  1. Configure the plugin with retainMode: "full-session" and auto-retain enabled.
  2. In a session, invoke any bundled skill (the size scales with the skill).
  3. Let the Stop hook fire.

Observed Behavior

Measured over my local transcripts, after applying the plugin's own strip_memory_tags():

retainable messages: 1413   total chars: 1,328,726
skill-body messages : 1 msg    566,804 chars (42.7%)
injected blocks     : 23 msgs   93,180 chars ( 7.0%)
combined                                      49.7%

A single claude-api skill invocation accounted for 42.7% of everything that session sent to extraction — one user message of 566,804 characters. Extraction turned it into ~1,600 world facts about the Anthropic SDK (budget_tokens deprecations, Bedrock client setup, effort levels) stored as facts about my work.

Downstream, an untagged whole-bank mental model then synthesised those into a "user profile" asserting model and API preferences I had never expressed. That is the part that took a while to notice — the facts look plausible and nothing marks them as documentation.

Another user reproduced the same failure independently on a separate setup with a 785 KB skill payload.

Expected Behavior

Skill bodies should not be retained as user conversation, and harness-injected blocks should be stripped the same way Hindsight's own injected blocks already are.

Environment

hindsight-memory plugin 0.7.5, self-hosted API, retainMode: full-session, retainToolCalls: false.

PR follows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions