Skip to content

Feature Request: Add preCompact hook event for context refresh before token compaction #1138

Closed

Description

@cephalin

Summary

Copilot CLI hooks are missing a preCompact event type that exists in Claude Code. This creates a gap for workflows that need to refresh context before token compaction (like Gas Town projects).

Background

Claude Code's .claude/settings.json supports a PreCompact hook that runs before context compaction:

{
  "hooks": {
    "PreCompact": [
      {
        "type": "command",
        "command": "gt prime --hook"
      }
    ]
  }
}

This is critical for projects like Gas Town where agents (mayor, deacon, refinery, witness, crew, polecats) need to:

  1. Inject fresh context via gt prime --hook on session start (sessionStart)
  2. Refresh that context right before compaction (PreCompact) to ensure accurate state before tokens are compressed

Problem

Copilot CLI currently supports:

  • sessionStart
  • sessionEnd
  • userPromptSubmitted
  • preToolUse
  • postToolUse
  • errorOccurred

But NOT preCompact. This means agents running in Copilot CLI have stale context after compaction, which breaks multi-hour workflows.

Request

Add support for a preCompact hook event (or expose the internal compaction_start event) in Copilot CLI's .github/hooks/*.json configuration format, matching Claude Code's behavior.

Impact

  • Enables Gas Town and similar systems to work reliably with Copilot CLI for long sessions
  • Maintains parity with Claude Code's hook ecosystem

Activity

  1. added
    area:context-memoryContext window, memory, compaction, checkpoints, and instruction loading
    on Apr 6, 2026
  2. examon commented on Apr 7, 2026

    @examon

    This was added in v1.0.5. The preCompact hook event is now available in the hooks configuration, so commands can run before context compaction starts. If you believe this isn't resolved, please feel free to reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:context-memoryContext window, memory, compaction, checkpoints, and instruction loading

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions