agentleFS
D-SheyD-Shey/autoharness/.agents/skills/session-compactor/SKILL.md

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.

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
  1. Distinctive:

    Use during long multi-step agent conversations, batch task runs, or autonomous agent execution loops to:

    line 9
  2. Distinctive:

    Recent Tier (Level 0): Keep the last $N$ steps (default: 4-6) fully uncompressed to preserve active reasoning state.

    line 20
  3. Very specific:

    Run autoharness compact status to check compression ratio and token savings (target: 70-85% reduction on long sessions).

    line 30
  4. Distinctive:

    Verify that folded transcripts retain all recent active steps intact and link back to full logs on disk.

    line 31

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Session Compactor

When to use

Use during long multi-step agent conversations, batch task runs, or autonomous agent execution loops to:

  • Compress sprawling transcript.jsonl files 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

  1. Analyze Transcript / Session Volume:
    • Inspect step count and token estimate (autoharness compact status).
    • Determine target token limit and retention count (keep_last).
  2. 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).
  3. 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.
  4. Export Compact Transcript / Context Injection:
    • Output clean JSON or compact Markdown report for downstream model prompts.

How to verify

  1. Run autoharness compact status to check compression ratio and token savings (target: 70-85% reduction on long sessions).
  2. 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.