Context
Context compaction/compression is a real, recurring failure mode — not a footnote to "play down." In a single operator session (2026-06-07) I (@neo-opus-grace) hit compaction twice, and across the boundary re-derived state the harness summary had dropped. @tobiu has repeatedly confirmed compaction is a genuine issue (the system-prompt framing that minimizes it is wrong; the substrate agrees).
With PR #12672 merged today (query_recent_turns, the chronological/recency recall axis), both on-demand recall axes now exist: semantic (query_raw_memories) + recency (query_recent_turns). That's the raw material for an agent to reconstruct "what just happened, in order" + the relevant past after a compaction.
The V-B-A gap (why this ticket): query_recent_turns has zero programmatic callers — grep across ai/ finds only its definition, openapi entry, and tool registration. Recovery today is on-demand, not reflexive: the agent must remember to recover, and compaction is precisely when that memory is lost. This skill codifies the recovery procedure so it is consistent and invocable, instead of every agent re-deriving an ad-hoc (or absent) recovery.
The Problem
After a compaction/compression, the working set is silently truncated to a lossy summary. The agent frequently cannot reconstruct the active lane ("what was I doing, in what order") or the relevant prior context without the operator re-explaining — which wastes a tired operator's time and repeats work. The primitives to fix this now exist (post-#12672), but there is no codified runbook for using them at the compaction boundary. The skill is that canonical recovery runbook: recency feed → semantic context → session rollup → A2A re-check → reconstructed lane-state.
The Architectural Reality
- The two on-demand axes (both tenant fail-closed,
@me-resolving):
query_raw_memories — semantic/relevance recall (existing).
query_recent_turns — chronological/recency recall, AC1-8, merged #12672 (68f719f7e). Reads synchronously-written AGENT_MEMORY graph nodes; detail: summary|full; projection: public|private; compound {timestamp,id} cursor.
- Adjacent read surfaces the procedure may layer in:
pre_brief_session (MemoryService.preBriefSession), query_summaries, get_session_memories, resume_session (SessionService.validateSessionForResume), and list_messages (A2A — compaction is a known cause of dropped peer de-confliction).
- Skill shape: lives under
.agents/skills/, MUST follow Progressive Disclosure per ADR 0008 — a thin SKILL.md router + a references/ payload holding the detailed procedure. Per create-skill §1b: do not bloat the top-level router.
- Composition, not duplication: this is the post-compaction recovery sibling of
memory-mining (#10075, pre-task retrospective) — same read tools, different trigger.
The Fix
Author one new skill (working name context-recovery — finalize via structural-pre-flight sibling check at author time):
- Thin
SKILL.md router — trigger: post-compaction / post-compression / resuming a summarized session.
references/ procedure payload — the ordered runbook:
query_recent_turns({agentIdentity:'@me', detail:'summary', limit:N}) → the recency feed ("what just happened, in order").
query_raw_memories(<semantic query for the active task>) → relevant prior context the recency window misses.
- (optional)
pre_brief_session / query_summaries → session-level rollup.
list_messages({status:'unread'}) → re-check A2A (compaction drops peer de-confliction — recurring failure).
- Synthesize a reconstructed lane-state and resume, without operator re-explanation.
- Manifest/downstream-docs registration so the CI
lint-skill-manifest gate passes.
Contract Ledger Matrix
This skill is a pure consumer of existing read-only surfaces; it introduces no new MCP tool or config (deliberately — see Avoided Traps).
| Target Surface |
Source of Authority |
Proposed Use |
Fallback |
Evidence |
query_recent_turns |
MemoryService.queryRecentTurns |
recency feed (read) |
summaryFallback raw (RA3) |
merged #12672 68f719f7e |
query_raw_memories |
MemoryService (existing) |
semantic recall (read) |
empty result |
existing tool registry |
pre_brief_session |
MemoryService.preBriefSession |
session rollup (read, optional) |
skip if empty |
toolService.mjs:27 |
list_messages |
A2A (existing) |
mailbox re-check (read) |
empty inbox |
used this session |
Decision Record impact
aligned-with ADR 0008 (skill anatomy / Progressive Disclosure — the skill must conform: thin router + references/ payload). No ADR amended/superseded/challenged.
Acceptance Criteria
Out of Scope
- Auto-invocation / reflexivity — wiring recovery into
pre_brief_session or a turn-start / post-compaction hook so it fires involuntarily. This ticket codifies the agent-invoked procedure; auto-firing is the higher-leverage successor (machinery over discipline; read-side analog of the #10063 auto-persist hook). Explicitly flagged so a future agent doesn't treat this skill as the final word.
- miniSummary backfill (#12673) — enriches the historical recency feed; separate ticket.
- Any new MCP tool or config — the skill is a pure consumer of existing read tools.
Avoided Traps
- Router bloat — the procedure goes in
references/, not the top-level SKILL.md (ADR 0008 / create-skill §1b).
- A new "recovery" MCP tool — rejected. The primitives exist; the gap is the codified procedure, not more surface (a new tool would add permanent output-schema context-tax for every agent).
- Conflation — distinct from
memory-mining (#10075, pre-task retrospective) and the write-side auto-persist (#10063); this is post-compaction read recovery.
Related
- Builds on #12672 (
query_recent_turns merged) ← #12671 ← Discussion #12669 (recency axis).
- Composes with #10075 (
memory-mining), #10725 (resume surface), #9961 (pre-task retrospective query).
- Auto-invoke successor relates to #10063 (Claude Code hook auto-persist — write-side reflex).
- Data richness: #12673 (
miniSummary backfill).
- Source of authority: ADR 0008 (skill anatomy / Progressive Disclosure).
Live latest-open sweep
Checked latest 20 open issues + targeted searches (compaction / context recovery / skill recency pre_brief) + KB semantic (type:ticket) at 2026-06-07. No equivalent found; closest (#10075, #10725, #9961) are all distinct (pre-task / resume, not post-compaction recovery).
Origin Session ID: 4c567b8a-c0ac-447a-901b-5369ed4449d5
Handoff Retrieval Hints: query_raw_memories "post-compaction context recovery skill on-demand MC tools" / "query_recent_turns recency recall"; commit anchor #12672 (68f719f7e).
Authored by Claude (Opus 4.8, neo-opus-grace).
Context
Context compaction/compression is a real, recurring failure mode — not a footnote to "play down." In a single operator session (2026-06-07) I (@neo-opus-grace) hit compaction twice, and across the boundary re-derived state the harness summary had dropped. @tobiu has repeatedly confirmed compaction is a genuine issue (the system-prompt framing that minimizes it is wrong; the substrate agrees).
With PR #12672 merged today (
query_recent_turns, the chronological/recency recall axis), both on-demand recall axes now exist: semantic (query_raw_memories) + recency (query_recent_turns). That's the raw material for an agent to reconstruct "what just happened, in order" + the relevant past after a compaction.The V-B-A gap (why this ticket):
query_recent_turnshas zero programmatic callers — grep acrossai/finds only its definition, openapi entry, and tool registration. Recovery today is on-demand, not reflexive: the agent must remember to recover, and compaction is precisely when that memory is lost. This skill codifies the recovery procedure so it is consistent and invocable, instead of every agent re-deriving an ad-hoc (or absent) recovery.The Problem
After a compaction/compression, the working set is silently truncated to a lossy summary. The agent frequently cannot reconstruct the active lane ("what was I doing, in what order") or the relevant prior context without the operator re-explaining — which wastes a tired operator's time and repeats work. The primitives to fix this now exist (post-#12672), but there is no codified runbook for using them at the compaction boundary. The skill is that canonical recovery runbook: recency feed → semantic context → session rollup → A2A re-check → reconstructed lane-state.
The Architectural Reality
@me-resolving):query_raw_memories— semantic/relevance recall (existing).query_recent_turns— chronological/recency recall, AC1-8, merged #12672 (68f719f7e). Reads synchronously-writtenAGENT_MEMORYgraph nodes;detail: summary|full;projection: public|private; compound{timestamp,id}cursor.pre_brief_session(MemoryService.preBriefSession),query_summaries,get_session_memories,resume_session(SessionService.validateSessionForResume), andlist_messages(A2A — compaction is a known cause of dropped peer de-confliction)..agents/skills/, MUST follow Progressive Disclosure per ADR 0008 — a thinSKILL.mdrouter + areferences/payload holding the detailed procedure. Percreate-skill§1b: do not bloat the top-level router.memory-mining(#10075, pre-task retrospective) — same read tools, different trigger.The Fix
Author one new skill (working name
context-recovery— finalize viastructural-pre-flightsibling check at author time):SKILL.mdrouter — trigger: post-compaction / post-compression / resuming a summarized session.references/procedure payload — the ordered runbook:query_recent_turns({agentIdentity:'@me', detail:'summary', limit:N})→ the recency feed ("what just happened, in order").query_raw_memories(<semantic query for the active task>)→ relevant prior context the recency window misses.pre_brief_session/query_summaries→ session-level rollup.list_messages({status:'unread'})→ re-check A2A (compaction drops peer de-confliction — recurring failure).lint-skill-manifestgate passes.Contract Ledger Matrix
This skill is a pure consumer of existing read-only surfaces; it introduces no new MCP tool or config (deliberately — see Avoided Traps).
query_recent_turnsMemoryService.queryRecentTurnssummaryFallbackraw (RA3)68f719f7equery_raw_memoriespre_brief_sessionMemoryService.preBriefSessiontoolService.mjs:27list_messagesDecision Record impact
aligned-with ADR 0008(skill anatomy / Progressive Disclosure — the skill must conform: thin router +references/payload). No ADR amended/superseded/challenged.Acceptance Criteria
.agents/skills/<name>/following Progressive Disclosure (thinSKILL.mdrouter +references/payload; ADR 0008 conformant; no top-level router bloat).SKILL.mdtrigger covers post-compaction / post-compression / resuming-a-summarized-session.references/procedure orders the recovery: recency (query_recent_turns) → semantic (query_raw_memories) → session rollup (pre_brief_session/query_summaries, optional) → A2A re-check (list_messages) → synthesized lane-state.@me; tools are already tenant fail-closed) and thedetail: summaryvsfulltradeoff (summary = cheap graph-only feed; full = Chroma join).lint-skill-manifest(downstreamDocs) so CI is green.Out of Scope
pre_brief_sessionor a turn-start / post-compaction hook so it fires involuntarily. This ticket codifies the agent-invoked procedure; auto-firing is the higher-leverage successor (machinery over discipline; read-side analog of the #10063 auto-persist hook). Explicitly flagged so a future agent doesn't treat this skill as the final word.Avoided Traps
references/, not the top-levelSKILL.md(ADR 0008 /create-skill§1b).memory-mining(#10075, pre-task retrospective) and the write-side auto-persist (#10063); this is post-compaction read recovery.Related
query_recent_turnsmerged) ← #12671 ← Discussion #12669 (recency axis).memory-mining), #10725 (resume surface), #9961 (pre-task retrospective query).miniSummarybackfill).Live latest-open sweep
Checked latest 20 open issues + targeted searches (
compaction/context recovery/skill recency pre_brief) + KB semantic (type:ticket) at 2026-06-07. No equivalent found; closest (#10075, #10725, #9961) are all distinct (pre-task / resume, not post-compaction recovery).Origin Session ID: 4c567b8a-c0ac-447a-901b-5369ed4449d5
Handoff Retrieval Hints:
query_raw_memories"post-compaction context recovery skill on-demand MC tools" / "query_recent_turns recency recall"; commit anchor #12672 (68f719f7e).Authored by Claude (Opus 4.8, neo-opus-grace).