lean-session plugin
OpenCode plugin that makes clear-over-compact safe for interactive sessions by preserving.agents/ state through context resets.
Source: templates/lean-compaction-plugin.ts in this repo.
Install: copy (compiled as JS) to ~/.config/opencode/plugins/lean-session.js.
Problem it solves
Clear-over-compact (starting a fresh context per task) loses in-session state: active task list, design decisions, loop iteration count. Without intervention, compaction silently discards the.agents/ scratchpad — the agent resumes with no memory of what it was doing.
lean-session injects .agents/ content into the compaction summary so it survives the reset.
Hooks
Files read / written
Checkpoint format
Written to.agents/checkpoint.md on session.idle:
Installation
~/.config/opencode/plugins/ at startup.
Why this matters
Without lean-session, compaction discards.agents/ — the agent loses its task list, decisions, and loop state. With it, the compaction summary carries all three forward. This is what makes the Lean Agentic Coding Workflow viable across multi-hour sessions with multiple context resets.
Related Pages
- OpenCode — the harness; plugin event surface
- AgentOps (boshu2) — the
.agents/directory convention this plugin reads from - Context Compression Strategies — clear-over-compact context strategy
- Ralph Loop —
loop-state.jsonsource; the AFK loop this checkpoints - Lean Agentic Coding Workflow — the workflow this plugin is a component of