session-compactor
Skill10 starsChanged todayMITView on GitHub
Dynamic multi-tiered context compaction and layered session transcript folding for agents. Use when agent context window exceeds token budgets during long-running sessions, multi-round tasks, or autonomous drive loops to collapse intermediate tool outputs and summarize past epochs while preserving full logs on disk.
In this repository44 other files it gives its agents.
- llms-full.txtllms.txt
- llms.txtllms.txt
- ai-prompt-engineering-safety-reviewSkill
- ast-codemapSkill
- ast-grepSkill
- autoharnessSkill
- autonomous-backlog-driverSkill
- claude-kimi-mcp-normalizationSkill
- cli-self-updaterSkill
- code-frugalitySkill
- codemode-gatewaySkill
- codemode-typesSkill
- consequence-simulationSkill
- context-pruningSkill
- github-update-checkerSkill
- google-agents-cli-evalSkill
- google-agents-cli-scaffoldSkill
- history-searchSkill
- hook-gatingSkill
- hybrid-semantic-searchSkill
- kimi-code-agent-integrationSkill
- kimi-mcp-configurationSkill
- leann-vectorSkill
- log-summarizerSkill
- markdown-vagueSkill
- memory-reconciliationSkill
- mode-classificationSkill
- multiagent-orchestrationSkill
- output-compressionSkill
- prompt-injectionSkill
- python-anti-patternsSkill
- regression-sentinelSkill
- restart-trackingSkill
- rollback-guardSkill
- rust-call-graphSkill
- secrets-managementSkill
- security-best-practicesSkill
- sqlite-memorySkill
- swarm-barrierSkill
- swarm-dagSkill
- autoharnessSkill
- code-reliability-checksSkill
- skill-threat-rulesSkill
- autoharnessSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Use during long multi-step agent conversations, batch task runs, or autonomous agent execution loops to:
- Distinctive: line 20
Recent Tier (Level 0): Keep the last $N$ steps (default: 4-6) fully uncompressed to preserve active reasoning state.
- Very specific: line 30
Run autoharness compact status to check compression ratio and token savings (target: 70-85% reduction on long sessions).
- Distinctive: line 31
Verify that folded transcripts retain all recent active steps intact and link back to full logs on disk.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Session Compactor
When to use
Use during long multi-step agent conversations, batch task runs, or autonomous agent execution loops to:
- Compress sprawling
transcript.jsonlfiles and tool outputs into tiered levels of detail. - Retain exact execution fidelity on recent steps while distilling noisy intermediate tool outputs (test suites, builds, grep searches).
- Condense completed task milestones or early epochs into high-density structured summaries.
- Maintain full reversibility by persisting uncompressed step traces to
.autoharness/folded/.
Steps
- Analyze Transcript / Session Volume:
- Inspect step count and token estimate (
autoharness compact status). - Determine target token limit and retention count (
keep_last).
- Inspect step count and token estimate (
- Apply Hierarchical Tiered Folding:
- Recent Tier (Level 0): Keep the last $N$ steps (default: 4-6) fully uncompressed to preserve active reasoning state.
- Distill Tier (Level 1): For intermediate steps, preserve caller intent and arguments, but compress long tool outputs (pytest, build, diffs) using cascading output compression (
compression.compress_output). - Epoch Tier (Level 2): For older completed milestones, aggregate steps into structured epoch summaries (
Goal -> Action Taken -> Outcome -> Evidence Artifacts).
- Persist and Link Reversible Traces:
- Save full raw steps to
.autoharness/folded/<session_id>-epoch-<N>.jsonl. - Embed lightweight backlink pointers (
[Full log: .autoharness/folded/...]) in the folded transcript so agents can drill down on demand.
- Save full raw steps to
- Export Compact Transcript / Context Injection:
- Output clean JSON or compact Markdown report for downstream model prompts.
How to verify
- Run
autoharness compact statusto check compression ratio and token savings (target: 70-85% reduction on long sessions). - Verify that folded transcripts retain all recent active steps intact and link back to full logs on disk.
Facts found here
- Intermediate pytest traces and large git diffs constitute over 80% of token consumption in multi-round agent sessions.
- Preserving the last 4-6 steps verbatim allows models to maintain immediate conversational momentum without hallucinating lost state.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

