agentsclimarketplace

Session memory first compaction

Skill ychampion/cskill-agents/agents/codex/skills/session-memory-first-compaction

Agent skills for coding CLIs, multi-agent runtimes, context engines, MCP extensions, and terminal tooling. Instead of using claude code's source code, give your agent skills to create your own!

Install
npx -y skills add ychampion/cskill-agents --skill session-memory-first-compaction

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

What its author says it does

Copied from the file, not written here

Attempt session-memory compaction before full conversation compaction so lightweight summaries win when available.

SKILL.md

1.9 KB, as published. Nobody here has run it

SKILL: Session Memory First Compaction

Domain: context-management
Trigger: Apply when an auto-compact flow can query a session-memory summary before running the heavier legacy compaction path. Source Pattern: Distilled from reviewed lightweight summary-first and fallback compaction implementations.

Core Method

When auto-compaction fires, try the lightweight session-memory summary path first. If it returns a usable summary, treat that as a successful compaction and skip the heavier full-conversation compaction path. Only fall back to the heavyweight path when the lightweight summary is unavailable. This keeps cached or precomputed summaries in charge whenever possible and reserves the costly path for true misses.

Key Rules

  • Try the lightweight session-memory compaction path before the heavyweight full-conversation path every time auto-compaction triggers.
  • On success, reset last summarized IDs and run any post-compact cleanup to keep boundary metadata in sync.
  • Notify prompt-cache break detection so repeated compactions don’t misreport context flushes.
  • Return early with wasCompacted: true so callers skip the fallback path.
  • Only fall through to compactConversation when session memory compaction returns null.

Example Application

Auto-compaction finds a fresh session-memory summary, accepts it as the compaction result, records success, and avoids calling the heavyweight compaction path at all.

Anti-Patterns (What NOT to do)

  • Don’t always run the heavyweight compaction first; you waste CPU and risk prompt-too-long errors that session memory could avoid.
  • Don’t skip the cleanup steps that reset lastSummarizedMessageId and notify cache detectors when the lightweight path wins.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.