Skip to content

feat: in-session compaction distiller subagent + advisory (0.25.0)#44

Merged
Shahinyanm merged 2 commits into
mainfrom
feat/compaction-distiller-subagent
Jun 13, 2026
Merged

feat: in-session compaction distiller subagent + advisory (0.25.0)#44
Shahinyanm merged 2 commits into
mainfrom
feat/compaction-distiller-subagent

Conversation

@Shahinyanm

Copy link
Copy Markdown
Member

What

When a conversation compacts, the segment's reasoning should land in the journal as typed events — so complete later leaves open only genuinely-unfinished tasks, not ones that merely look interrupted by a compaction. The user's constraint: do it in-session (no separately-billed claude -p) and without blocking the main chat.

Design (verified against platform limits)

Confirmed via claude-code-guide:

  • A hook cannot spawn a subagent — hook output is advisory; only the main model spawns subagents.
  • PreCompact decision:block blocks compaction but does not force a model turn (only Stop does — and even mempalace defaults to non-blocking).
  • Subagents support background: true — in-session (subscription, not separately billed), ~5k token overhead vs claude -p's ~46k.
  • The segment persists in the transcript JSONL on disk, so a subagent can read it after compaction.

So the closest achievable:

  1. task-journal-distiller subagent (plugin/agents/, Haiku, background: true): reads the active task's events + the transcript segment, records the missed decisions/rejections/findings via the journal MCP, never closes, dedup-aware.
  2. Advisory injection: after a compaction, SessionStart adds a short note suggesting the main agent delegate the segment to the distiller (TJ_DISTILLER_HINT=0 to disable). Advisory because hooks can't force it.
  3. Deterministic catch-up stays the guaranteed net — raw segment capture even if the model doesn't delegate.

Honest gaps (tracked follow-ups)

  • Advisory, not forced (platform limit) — net covers it.
  • /clear fires SessionEnd(clear), not Stop → needs a SessionEnd catch-up (claude-memory-mgc).
  • Investigate why the current catch-up+worker under-records (claude-memory-yvh) — may be the real "interrupted" cause.

Tests

session_start compact test asserts the distiller advisory appears; startup test asserts it does not. Full local gate green (fmt, clippy -D warnings, test --workspace).

🤖 Generated with Claude Code

Shahinyanm and others added 2 commits June 13, 2026 22:19
One-shot claude -p calls now pass --disallowed-tools (we never use
tools), keeping built-in tool schemas out of the prompt — roughly halves
the harness overhead. Stats lead with the real dollar cost for claude -p
(its token counts are muddy: a big prompt lands in cache_creation, not
input_tokens) and show clean tokens only for API backends; sizes scale
to M. A tip points at --backend anthropic (~50× cheaper) / ollama (free)
when a cost-reporting backend is used.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…dvisory

New task-journal-distiller subagent (Haiku, background:true): reads a
just-compacted conversation segment from the transcript file and
backfills the missed decisions/rejections/findings for the active task
via the journal MCP, never closing it. In-session → no separate claude
-p call (~5k vs ~46k overhead), non-blocking. After a compaction the
SessionStart hook adds a short advisory to delegate to it (hooks can't
spawn subagents, so it's advisory; deterministic catch-up stays the net).
TJ_DISTILLER_HINT=0 disables the hint.

Platform constraints verified via claude-code-guide; see
.docs/plans/2026-06-13-compaction-distiller.md. Worker-reliability fix
and SessionEnd(clear) catch-up tracked as follow-ups.

claude-memory-80f

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Shahinyanm Shahinyanm merged commit 266aef4 into main Jun 13, 2026
7 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