Skip to content

Feature Request: Add compaction_model config option for preemptive-compaction hook #828

@itzxSage

Description

@itzxSage

Summary

The preemptive-compaction hook currently uses the same model as the conversation for summarization. This causes 400 errors when using Claude thinking models (e.g., antigravity-claude-opus-4-5-thinking-medium) because the compaction request format is incompatible with Claude's thinking API.

Problem

When a session uses a Claude thinking model via Antigravity:

  1. Context grows past the threshold (e.g., 70%)
  2. Preemptive compaction triggers
  3. Hook calls session.summarize() with the same model (Claude Opus 4.5 Thinking)
  4. API returns 400 "Request contains an invalid argument"

Error from session logs:

{
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.\n\n[Debug Info]\nRequested Model: antigravity-claude-opus-4-5-thinking-medium\nEffective Model: claude-opus-4-5-thinking\nStatus: 400"
  }
}

Root Cause

In src/hooks/preemptive-compaction/index.ts (lines 114-115, 172-177):

const modelID = lastAssistant.modelID ?? ""
const providerID = lastAssistant.providerID ?? ""
// ...
const summarizeBody = { providerID, modelID, auto: true }

The hook unconditionally uses the conversation's model for compaction.

Proposed Solution

Add a compaction_model config option under experimental:

{
  "experimental": {
    "preemptive_compaction": true,
    "preemptive_compaction_threshold": 0.70,
    "compaction_model": "google/antigravity-gemini-3-pro-low"
  }
}

When set, the hook should use this model instead of the session's model:

const configModel = config.experimental?.compaction_model
const modelID = configModel ? parseModelID(configModel) : lastAssistant.modelID ?? ""
const providerID = configModel ? parseProviderID(configModel) : lastAssistant.providerID ?? ""

Benefits

  1. Avoid API errors with thinking models that don't support compaction requests
  2. Cost savings by using cheaper models (e.g., Gemini Flash) for summarization
  3. Consistency with how small_model works in opencode.json

Workaround

Currently disabling preemptive compaction entirely:

{
  "experimental": {
    "preemptive_compaction": false
  }
}

Environment

  • oh-my-opencode: 2.14.0
  • Model: google/antigravity-claude-opus-4-5-thinking-medium
  • Provider: Google Antigravity

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttriage:bugConfirmed bug with repro steps

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions