hook-preemptive-compaction

Monitor context window usage and trigger preemptive compaction prompts.

Updated Apr 12, 2026
One-click install
npx skills add https://github.com/xuezhaojun/oh-your-opencode --skill hook-preemptive-compaction
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hook-preemptive-compaction
Source: https://github.com/xuezhaojun/oh-your-opencode/tree/main/.opencode/skills/hook-preemptive-compaction
Command: npx skills add https://github.com/xuezhaojun/oh-your-opencode --skill hook-preemptive-compaction

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Monitors context window usage and triggers preemptive compaction prompts to avoid hitting the context limit.

Core Features & Use Cases

  • Monitors context window usage and prompts preemptive compaction to prevent token-waste emergencies.
  • Periodically injects a short reminder message (~50 tokens) suggesting the user run /compact.
  • Configurable threshold (default 0.7) and optional prompt to customize the reminder.

Quick Start

Configure the hook with your preferred threshold and optional prompt, then enable it in your harness.

Frequently Asked Questions about hook-preemptive-compaction

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent hitting the context window limit in long-running AI agent sessions?

Preemptive compaction monitors context window usage and triggers a prompt to run /compact before hitting the context limit, preventing emergency compactions that waste tokens in long-running AI agent sessions.

What is preemptive compaction for AI context management?

Preemptive compaction is a context management technique that periodically injects a short reminder message to trigger context summarization before the context window fills up, reducing token waste from emergency compactions.

How do I configure the context window threshold for preemptive compaction?

You can configure the preemptive compaction threshold by setting a custom value (the default is 0.7) and an optional prompt in your harness, enabling the hook to trigger compaction reminders at your preferred context window capacity.

Does preemptive compaction work with high-context workflows?

Yes, preemptive compaction is specifically applicable to high-context workflows and long-running sessions where token waste from emergency compactions is a concern, injecting periodic reminders to manage the context window proactively.

How many tokens does the preemptive compaction reminder message consume?

The preemptive compaction reminder message consumes approximately 50 tokens, periodically injecting a short prompt into the context window to suggest running the /compact command without adding significant token overhead.