Skip to content

fix(claude-code): filter injected harness turns from retention - #3024

Closed
runbgp wants to merge 1 commit into
vectorize-io:mainfrom
runbgp:fix/claude-code-filter-injected-turns
Closed

fix(claude-code): filter injected harness turns from retention#3024
runbgp wants to merge 1 commit into
vectorize-io:mainfrom
runbgp:fix/claude-code-filter-injected-turns

Conversation

@runbgp

@runbgp runbgp commented Jul 28, 2026

Copy link
Copy Markdown

Fixes #3023.

Claude Code records an invoked skill's full SKILL.md as an ordinary user message, and injects <system-reminder> / <task-notification> blocks into user turns. Both were retained verbatim. On my transcripts that was ~50% of everything sent to extraction, and one skill invocation alone was a single 566 KB user message.

Same shape as the Codex fix in #1346:

  • is_synthetic_user_message() — skips user turns starting with Base directory for this skill: , applied once in prepare_retention_transcript() so it covers both the text and JSON formats.
  • strip_harness_blocks() — removes the two block types, alongside the existing strip_memory_tags() call on the retain path.

Recall query composition is left alone; this only touches retention.

Tests added for both functions and for the retention path. uv run pytest tests passes (213). No new ruff findings — the two pre-existing F541s in setup_hooks.py and the import-sort in test_content.py are untouched.

Claude Code records an invoked skill's full SKILL.md as a user message and
injects <system-reminder>/<task-notification> blocks into user turns. Both
were retained verbatim, storing harness output as if the user had written it
and producing very large retain payloads.

Mirrors the Codex fix in vectorize-io#1346.
@nicoloboschi

Copy link
Copy Markdown
Collaborator

Closing: superseded by Coding Agents, which handles this class structurally — and your report is part of why it now handles it properly.

Measured against 400 real transcripts there: skill bodies arrive with isMeta: true (8/8) and are dropped with every other meta line, and <system-reminder> rides inside tool_result blocks, which the reader drops entirely. What was leaking were two cases neither of us had listed — <task-notification> (39 records) and Claude Code's compaction summary (29 records, 474,016 chars, retained as if the user typed them). Both are fixed: #3378 and #3383.

npx @vectorize-io/hindsight-coding-agents install claude-code (docs).

@runbgp
runbgp deleted the fix/claude-code-filter-injected-turns branch August 12, 2026 14:13
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.

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

2 participants