Skip to content

feat(compaction): L3 microcompact dual-path, cache-state-driven (M4.3… - #28

Merged
wusijian007 merged 1 commit into
mainfrom
feat/m4.3-l3-microcompact-dualpath
Jun 19, 2026
Merged

wusijian007 merged 1 commit into
mainfrom
feat/m4.3-l3-microcompact-dualpath

Conversation

@wusijian007

Copy link
Copy Markdown
Owner

… / v4)

The marquee layer: microcompact keeps the N newest tool_result blocks and clears all older ones to a marker (count-based, transcript-wide — so it reaches tool results inside the recent window too, unlike L2's stale-zone snip). The defining idea is that infrastructure state decides the algorithm: a cache-warmth clock picks the path, and both paths make zero extra API calls.

  • COLD (more than microcompactColdMs ~5 min has elapsed since the last model call, so the prefix cache is already expired): clear older tool results in place — free, the prefix rebuilds anyway.

  • HOT (prefix still warm): defer — preserve the warm prefix. The gateway does not expose Anthropic cache_edits, so the hot path cannot free the prefix for free; deferring is the faithful native adaptation (see docs/v4-compaction-pipeline-roadmap.md M4.3). Honest consequence: continuous operation is HOT, so L3 mostly defers within a run and acts on idle/resume.

  • core: microcompactToolResults + MicrocompactOptions (context.ts); query loop tracks lastModelCallAt via an injectable QueryOptions.now clock, computes cacheWarmth at the turn boundary, inserts the microcompact stage as [spill, snip, microcompact, reclaim], and marks query.microcompact_cold.

  • tests: 2 L3 unit tests (keeps newest N + clears older, preserves artifactPath; no-op when <= N); 1 integration test driving cold vs hot via the injected clock and asserting the profile mark.

  • docs: CLAUDE.md query-loop step 7 lists L3 + the warmth clock; v4 roadmap M4.3 delivered with the cache_edits caveat called out.

235 tests pass (+3); all 10 eval tasks green (L3 dormant/hot in continuous eval), fingerprint unchanged.

… / v4)

The marquee layer: microcompact keeps the N newest tool_result blocks and clears
all older ones to a marker (count-based, transcript-wide — so it reaches tool
results inside the recent window too, unlike L2's stale-zone snip). The defining
idea is that infrastructure state decides the algorithm: a cache-warmth clock
picks the path, and both paths make zero extra API calls.

- COLD (more than microcompactColdMs ~5 min has elapsed since the last model
  call, so the prefix cache is already expired): clear older tool results in
  place — free, the prefix rebuilds anyway.
- HOT (prefix still warm): defer — preserve the warm prefix. The gateway does
  not expose Anthropic cache_edits, so the hot path cannot free the prefix for
  free; deferring is the faithful native adaptation (see
  docs/v4-compaction-pipeline-roadmap.md M4.3). Honest consequence: continuous
  operation is HOT, so L3 mostly defers within a run and acts on idle/resume.

- core: microcompactToolResults + MicrocompactOptions (context.ts); query loop
  tracks lastModelCallAt via an injectable QueryOptions.now clock, computes
  cacheWarmth at the turn boundary, inserts the microcompact stage as
  [spill, snip, microcompact, reclaim], and marks query.microcompact_cold.
- tests: 2 L3 unit tests (keeps newest N + clears older, preserves artifactPath;
  no-op when <= N); 1 integration test driving cold vs hot via the injected
  clock and asserting the profile mark.
- docs: CLAUDE.md query-loop step 7 lists L3 + the warmth clock; v4 roadmap M4.3
  delivered with the cache_edits caveat called out.

235 tests pass (+3); all 10 eval tasks green (L3 dormant/hot in continuous eval),
fingerprint unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@wusijian007
wusijian007 merged commit bcae96d into main Jun 19, 2026
3 checks passed
@wusijian007
wusijian007 deleted the feat/m4.3-l3-microcompact-dualpath branch June 19, 2026 21:55
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