Agent skill

Compaction UI

by LeoYeAI in LeoYeAI/openclaw-master-skills

Background memory compaction with auto-trigger, chat summary paragraph, configurable threshold, model selector, settings tab, and result storage for OpenClaw Control UI.

MITAuto-check passed

Install Compaction UI

skills CLI
$ npx skills add LeoYeAI/openclaw-master-skills --skill compaction-ui -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install LeoYeAI/openclaw-master-skills compaction-ui --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/LeoYeAI/openclaw-master-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/compaction-ui-enhancements .claude/skills/compaction-ui && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
compaction-ui
GitHub stars
2.2k
Token cost
~2.7k tokens
SKILL.md length
1,073 words
Files
8 (incl. references)
Skills in repo
972
Repo updated
First seen
Licence
MIT

At a glance

Background memory compaction with auto-trigger, chat summary paragraph, configurable threshold, model selector, settings tab, and result storage for OpenClaw Control UI.

  • Works in 8 steps: Context Gauge Button… → Background Compaction (Toast) → Auto-Compaction → …
  • SKILL.md covers Status: ✅ Active, Features, Architecture and Known Gotchas, plus 1 more section
  • Runs TypeScript scripts from its folder

What it does

Compaction UI is an agent skill from LeoYeAI/openclaw-master-skills. Background memory compaction with auto-trigger, chat summary paragraph, configurable threshold, model selector, settings tab, and result storage for OpenClaw Control UI.

Its SKILL.md is about 2.7k tokens, which your agent loads only when the skill is triggered. The skill folder holds 8 other files, including reference files (for example `references/auto-compaction.ts`, `references/chat-filters.diff.md` and `references/compact-summary-injection.ts`).

The repository describes itself as: 🧠 Curated collection of 1209+ best OpenClaw skills — weekly updated by MyClaw.ai. The licence is MIT.

Example prompts

  • “/compaction-ui”

Requirements

  • Node.js

Workflow steps

8 steps, taken from the step headings in SKILL.md.

  1. Context Gauge Button (app-render.helpers.ts)
  2. Background Compaction (Toast)
  3. Auto-Compaction
  4. Conversation Summary Paragraph
  5. Settings Tab (Plugin-Registered)
  6. Auth Hierarchy
  7. Result Storage
  8. Chat History Filters

What it can do on your machine

Read from SKILL.md and the folder at commit e5199b5. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (TypeScript), which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Compaction UI loads about 2.7k tokens when it runs, and up to ~13k if it reads all its reference files. Until then it costs about 46 tokens; SKILL.md has 1,073 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~46
When it runs · the whole SKILL.md, loaded when a task matches
~2.7k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~13k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from LeoYeAI/openclaw-master-skills at commit e5199b5, republished under its MIT licence (© LeoYeAI). 1,073 words, ~2,726 tokens.

Download SKILL.mdSave it as .claude/skills/compaction-ui/SKILL.md (or your agent's skills folder). This skill also uses 7 other files; get the full folder from GitHub.
name
compaction-ui
description
Background memory compaction with auto-trigger, chat summary paragraph, configurable threshold, model selector, settings tab, and result storage for OpenClaw Control UI.
version
2.3.0

Compaction UI v2.1.0

Memory compaction system for the OpenClaw Control UI — background execution with toast notifications, auto-trigger at configurable token thresholds, conversation summary paragraphs in compacted output, dedicated settings tab with model selector, and result history.

Status: ✅ Active

ComponentStatus
Context Gauge Button✅ Working
Background Compaction (toast)✅ Working
Auto-Compaction Trigger✅ Working
Conversation Summary Paragraph✅ Working
Settings Tab (plugin-registered)✅ Working
Model Selector✅ Working
Last Result Storage + Viewer✅ Working
Settings Persistence & Reload✅ Working
Auth Hierarchy (OAuth > API > Fallback)✅ Working
Chat History Filters✅ Working
Full Background Isolation (no chat interference)✅ Working

Features

1. Context Gauge Button (app-render.helpers.ts)

A circular SVG progress ring in the chat toolbar that doubles as the manual compact trigger.

  • Placement: After session selector dropdown in renderChatControls()
  • Data source: sessionsResult.sessions[].totalTokens and contextTokens from session rows
  • Colors: Green (<60%), Yellow (60-85%), Red (≥85%)
  • Disabled: When utilization <20% or during active compaction
  • Tooltip: Shows "Context: XK / YK tokens (Z%)"
2. Background Compaction (Toast)

On click (or auto-trigger), compaction runs in the background using the standard bottom-right toast system — no blocking modal. The UI remains fully interactive.

  • Running toast: Shows "Memory Compaction" with spinner
  • Complete toast: Shows "Compacted: XK → YK" with checkmark (auto-dismisses after 5s)
  • Error toast: Shows failure message (auto-dismisses after 5s)
  • Uses backgroundJobToasts system consistent with all other background processes (cron, knowledge extraction, etc.)
3. Auto-Compaction

After every chat response (final event), the UI checks token usage against the configured threshold. If exceeded:

  • Background compaction triggers automatically
  • Toast shows "Auto-Compacting (X%)" with the current utilization
  • 5-minute debounce prevents repeated triggers
  • Chat refreshes automatically after successful compaction
  • Silent toast removal if nothing was compacted
4. Conversation Summary Paragraph

Every compaction output now begins with a ## Conversation Summary section before the structured ## Goal section. This is a 3-6 sentence natural language paragraph that:

  • Describes the overall topic(s) of the conversation
  • Explains the flow of discussion and key transitions
  • Summarizes how the conversation progressed
  • Written in past tense as a narrative overview

Implementation: Custom instructions are injected into the upstream compaction LLM call via compact.ts. The instruction is prepended to any user-provided custom instructions (from /compact [instructions]), so both coexist.

Example output:

## Conversation Summary
The conversation began with the user requesting improvements to the compaction
system, specifically moving from a blocking modal to background toasts. Discussion
then shifted to adding a settings tab with auto-compaction controls. After
implementing and testing those features, the user noticed settings weren't
persisting across tab navigations, which led to a fix for the module-level
state cache. Finally, the user requested adding a narrative summary paragraph
to the compaction output for better context.

## Goal
...
5. Settings Tab (Plugin-Registered)

A dedicated Compaction tab under the Agent navigation group, registered via the Plugin UI architecture.

Registration: plugins-ui.ts → BUILTIN_UI_VIEWS with id: "compaction", group: "agent", position: 7, icon: "archive"

Cards:

Auto-Compaction Card
  • Toggle: Enable/disable automatic compaction
  • Threshold slider: 10% to 95% (default: 60%)
  • Color-coded: Green (<60%), Yellow (60-85%), Red (≥85%)
Model Card
  • Dropdown: Select a specific model for compaction or use session default
  • Grouped by provider with context window sizes shown
  • Warning callout when custom model selected (API key reminder)
  • Fallback: If custom model fails, automatically falls back to session default
Result Storage Card
  • Toggle: Opt-in to save the compacted summary text for review
Last Compaction Card
  • Before/After: Large styled token counts in a 2-column grid
  • Stats: Tokens saved, percent reduction, trigger type, timestamp, session key
  • View Results: Expandable summary viewer (when storage is enabled)
  • Clear: Reset stored result
  • Hint: Shows "Enable Store Results" message when storage is off

State Management:

  • Module-level state persists across re-renders within a session
  • Settings reload from backend every time the tab is visited (2-second staleness threshold)
  • resetCompactionSettingsState() exported for tests and tab switches
6. Auth Hierarchy

Compaction uses resolveApiKeyForProvider via getApiKeyForModel — the same auth chain as chat:

OAuth → API Key → Fallback

No separate configuration needed. If OAuth (Claude Max) is configured as the primary auth profile, compaction uses it automatically. Custom model selection uses this same auth chain independently.

7. Result Storage

When enabled, the most recent compaction result is persisted to {agentDir}/compaction-config.json:

json
{
  "settings": {
    "autoEnabled": true,
    "autoThresholdPercent": 60,
    "storeLastResult": true,
    "compactionModel": "anthropic/claude-sonnet-4-6"
  },
  "lastResult": {
    "timestamp": 1709283600000,
    "trigger": "manual",
    "tokensBefore": 50614,
    "tokensAfter": 4766,
    "tokensSaved": 45848,
    "percentReduction": 91,
    "sessionKey": "agent:main:main",
    "summary": "## Conversation Summary\nThe conversation focused on...\n\n## Goal\n..."
  }
}

When storage is disabled, metadata (timestamps, token counts) is still saved but the summary text is omitted.

8. Chat History Filters
  • NO_REPLY/HEARTBEAT_OK filtering: Skips assistant messages with these exact texts
  • Compaction divider: Renders labeled divider line for __openclaw.kind === "compaction" messages

Architecture

Show full SKILL.md (443 more words)Show less
Backend RPCs
MethodDescription
sessions.compactExecute compaction (records result after completion)
compaction.getSettingsRead settings from config file
compaction.saveSettingsUpdate settings (threshold auto-clamped 10-95%)
compaction.getLastResultGet stored last compaction result
compaction.clearLastResultClear stored result
Files Modified
FilePurpose
src/gateway/server-methods/compaction.tsSettings RPCs, config I/O, result recording
src/gateway/server-methods/sessions.tssessions.compact RPC (records result after compaction)
src/gateway/server-methods/plugins-ui.tsPlugin view registration
src/gateway/server-methods.tsHandler wiring
src/gateway/server-methods-list.tsMethod registration
src/gateway/method-scopes.tsScope registration
src/agents/pi-embedded-runner/compact.tsChat summary instruction injection
ui/src/ui/app-render.helpers.tsContext gauge + background toast trigger
ui/src/ui/app-gateway.tsAuto-compaction check after final event
ui/src/ui/views/compaction-settings.tsSettings tab view
ui/src/ui/app-render.tsView wiring + import
ui/src/ui/views/chat.tsChat history filters
Config File

{agentDir}/compaction-config.json — per-agent, created on first settings save.

Plugin Registration

The compaction tab is registered as a builtin plugin view in plugins-ui.ts:

typescript
{
  id: "compaction",
  label: "Compaction",
  subtitle: "Memory Management",
  icon: "archive",
  group: "agent",
  position: 7,
  pluginId: "compaction-ui",
}

Known Gotchas

  • Settings not persisting across tab visits: Fixed in v2.1.0. The module-level _state.loaded flag was preventing reloads. Now reloads every 2 seconds when re-entering the tab.
  • Model selector requires API keys: If you select a custom model, make sure the provider's API key is configured. The UI shows a warning callout.
  • Compaction model format: Must be "provider/model" format (e.g. "anthropic/claude-sonnet-4-6"). Invalid formats are silently ignored and fall back to session default.
  • parentId skip-set propagation must be message-only: When filtering memory flush messages from readSessionMessages, the skip set must ONLY propagate through entries with a message field. Non-message protocol entries (type:"custom") bridge between logical turns — if their IDs enter the skip set, the entire remaining conversation gets hidden. The fix: only check parsed?.message entries against the skip set, and only add their IDs to it.
  • No blocking modal — ever: The gauge button in app-render.helpers.ts must NEVER render a full-screen overlay modal. Compaction is a background process; all status is communicated via the bottom-right toast system. Remove any position:fixed; inset:0 overlay conditioned on compactState.phase. The button may show a spinner icon while running, but must not block the UI.

Changelog

v2.1.0
  • Conversation summary paragraph: Compaction output now starts with a ## Conversation Summary narrative paragraph before structured sections
  • Model selector: Choose a specific model for compaction or use session default, with provider-grouped dropdown
  • Settings reload fix: Tab now reloads settings from backend every 2s instead of caching forever
  • Reference files updated: Synced references/ with current source
v2.0.0
  • Background compaction: Replaced blocking full-screen modal with background job toast
  • Auto-compaction: Triggers after chat response when token usage exceeds threshold (configurable, default 60%, 5-minute debounce)
  • Settings tab: Plugin-registered Compaction tab under Agent nav group
  • Result recording: sessions.compact records before/after token counts and optional summary
  • Auth hierarchy: Same OAuth → API → Fallback chain as chat
  • Settings RPCs: compaction.getSettings, compaction.saveSettings, compaction.getLastResult, compaction.clearLastResult
v1.0.0
  • Initial release: Context gauge button, blocking modal with animated phases, sessions.compact RPC with LLM summarization, chat history NO_REPLY/HEARTBEAT_OK filtering, compaction divider lines

© LeoYeAI, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 7 other files (references) in skills/compaction-ui-enhancements of LeoYeAI/openclaw-master-skills.

  • SKILL.md
  • references/auto-compaction.ts
  • references/chat-filters.diff.md
  • references/compact-summary-injection.ts
  • references/compaction-rpc.ts
  • references/compaction-settings-view.ts
  • references/context-gauge-ui.diff.md
  • references/sessions-compact-rpc.diff.md

Open the folder on GitHubat commit e5199b5

Compare with similar skills

Compaction UI next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Compaction UI compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Compaction UI this skillLeoYeAI/openclaw-master-skills2.2k—~2.7kAutomated safety check: PassMIT
Strategic Compactaffaan-m/ECC275k1 repos~2.1kAutomated safety check: PassMIT
Python Background Jobswshobson/agents40k—~1.8kAutomated safety check: PassMIT
Backgroundjeremylongshore/tons-of-skills-marketplace2.8k—~2.2kAutomated safety check: PassMIT
Compactcatlog22/Claude-Code-Workflow2.1k—~3.2kAutomated safety check: PassMIT
Strategic Compactaffaan-m/ECC275k2 repos~434Automated safety check: PassMIT

Similar skills

  • Strategic Compact

    affaan-m/ECC

    Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.

    275k GitHub starsUsed in 1 repo~2.1k tokens
    Agent WorkflowsAuto-check passed
  • Python Background Jobs

    wshobson/agents

    Python background job patterns including task queues, workers, and event-driven architecture.

    40k GitHub stars~1.8k tokensUpdated 4 days ago
    Backend & APIsAuto-check passed
  • Background

    jeremylongshore/tons-of-skills-marketplace

    A skill your agent uses when the user wants to see, inspect, cancel, or prune background agents fired during prior chain runs.

    2.8k GitHub stars~2.2k tokensUpdated yesterday
    Auto-check passed
  • Compact

    catlog22/Claude-Code-Workflow

    Compact current session memory into structured text for session recovery.

    2.1k GitHub stars~3.2k tokensUpdated 3 mo ago
    Agent WorkflowsAuto-check passed
  • Strategic Compact

    affaan-m/ECC

    任意の自動コンパクションではなく、タスクフェーズを通じてコンテキストを保持するための論理的な間隔での手動コンパクションを提案します。

    275k GitHub starsUsed in 2 repos~434 tokens
    Auto-check passed
  • Strategic Compact

    affaan-m/ECC

    임의의 자동 컴팩션 대신 논리적 간격에서 수동 컨텍스트 압축을 제안하여 작업 단계를 통해 컨텍스트를 보존합니다.

    275k GitHub starsUsed in 2 repos~724 tokens
    Auto-check passed

More from LeoYeAI/openclaw-master-skills

All 972 skills in this repo
  • DevOps Pipeline Management

    LeoYeAI/openclaw-master-skills

    Manages pipelines on a DevOps quality and efficiency platform through its OpenAPI: list workspaces and templates, create, update, run and cancel pipelines, and read run records.

    2.2k GitHub stars~4.2k tokensUpdated 2 mo ago
    Auto-check: notes
  • Feishu Document Collaboration

    LeoYeAI/openclaw-master-skills

    Patches OpenClaw's Feishu extension so an edited document triggers an isolated agent session that reads the doc and replies inline, turning it into a live chat space.

    2.2k GitHub stars~2k tokensUpdated 2 mo ago
    Auto-check passed
  • Files Memory System

    LeoYeAI/openclaw-master-skills

    Multi-context memory management system for OpenClaw agents with group-isolated storage, global shared memory, workspace organization, and group-specific skills isolation.

    2.2k GitHub stars~3.8k tokensUpdated 2 mo ago
    Auto-check passed
  • GEO-Claw AI Visibility Agent

    LeoYeAI/openclaw-master-skills

    Runs a brand's AI-search visibility work end to end: diagnosing how AI platforms represent it, repositioning it, producing AI-optimized content and monitoring ongoing mentions.

    2.2k GitHub stars~4.7k tokensUpdated 2 mo ago
    Auto-check passed
  • Google Workspace CLI

    LeoYeAI/openclaw-master-skills

    Installs and authenticates the gws CLI, then automates Gmail, Drive, Sheets, Calendar, Docs, Chat and Tasks with ready-made recipes, persona bundles and security audits.

    2.2k GitHub stars~2.6k tokensUpdated 2 mo ago
    Auto-check: notes
  • HealthFit Health Advisors

    LeoYeAI/openclaw-master-skills

    Runs four advisor roles, a fitness coach, nutritionist, data analyst and TCM practitioner, to build a health profile and track workouts, diet and wellness over time.

    2.2k GitHub stars~4.4k tokensUpdated 2 mo ago
    Auto-check passed

Questions about Compaction UI

What does Compaction UI do?

Background memory compaction with auto-trigger, chat summary paragraph, configurable threshold, model selector, settings tab, and result storage for OpenClaw Control UI. Compaction UI is an agent skill from LeoYeAI/openclaw-master-skills. Background memory compaction with auto-trigger, chat summary paragraph, configurable threshold, model selector, settings tab, and result storage for OpenClaw Control UI.

How do I install Compaction UI in Claude Code?

Run `npx skills add LeoYeAI/openclaw-master-skills --skill compaction-ui -a claude-code`. Or copy the skill folder (skills/compaction-ui-enhancements in LeoYeAI/openclaw-master-skills) into .claude/skills/compaction-ui in your project. Claude Code loads it when a task matches its description.

How do I install Compaction UI in Codex?

Run `npx skills add LeoYeAI/openclaw-master-skills --skill compaction-ui -a codex`. Or copy the skill folder (skills/compaction-ui-enhancements in LeoYeAI/openclaw-master-skills) into .agents/skills/compaction-ui in your project. Codex loads it when a task matches its description.

Can I use Compaction UI in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add LeoYeAI/openclaw-master-skills --skill compaction-ui -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/compaction-ui, .gemini/skills/compaction-ui, .github/skills/compaction-ui and .opencode/skills/compaction-ui in your project.

What does Compaction UI need to run?

Going by SKILL.md and its folder, Compaction UI needs TypeScript for the scripts in its folder. Our summary lists: Node.js.

Does Compaction UI access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Compaction UI safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Compaction UI use?

Compaction UI is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Compaction UI use?

About 2.7k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 9.9k tokens, read only when the agent opens those files.

What are the alternatives to Compaction UI?

Skills that share tags, products or a category with Compaction UI: Strategic Compact (affaan-m/ECC, 275k stars), Python Background Jobs (wshobson/agents, 40k stars), Background (jeremylongshore/tons-of-skills-marketplace, 2.8k stars) and Compact (catlog22/Claude-Code-Workflow, 2.1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Compaction UI?

LeoYeAI (a GitHub user) maintains it in LeoYeAI/openclaw-master-skills, which has 2,159 GitHub stars. The repository holds 972 skills in this directory. The repository was last updated on July 20, 2026.

Source: LeoYeAI/openclaw-master-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.