Skip to content

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

@cephalin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions