GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [FEATURE]: Improve compaction prompt to preserve critical context details · Issue #16512 · anomalyco/opencode

[FEATURE]: Improve compaction prompt to preserve critical context details #16512

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
[FEATURE]: Improve compaction prompt to preserve critical context details#16512
Copy link
Assignees
nexxeln

Description

@lazyalex616
lazyalex616
opened on Mar 7, 2026
Issue body actions

Problem

I use GitHub Copilot as my provider. Disabling auto-compaction is not an option — Copilot enforces a hard token limit and the session crashes with context overflow if compaction is off. So I'm forced to rely on it.

The compaction prompt in packages/opencode/src/session/compaction.ts is too generic. It tells the LLM to summarize "what was done, what we're doing, which files we're working on, what we're going to do next" — but doesn't instruct it to preserve:

  • User-pasted content (conversation logs, error output, config snippets) — gets summarized into nothing. Post-compaction the AI has no idea what was pasted.
  • Exact technical details — flag names, config field paths, error messages, version numbers get generalized into vague descriptions.
  • User-stated constraints and preferences — "don't do X", workflow instructions, communication style constraints vanish.
  • Debugging state — which hypotheses were tested and ruled out, with what evidence.

The result: after compaction the AI repeats questions already answered, forgets user constraints, and loses investigation state. Often worse than starting a fresh session.

Compaction threshold (related)

Additionally, for a 200k context model with OUTPUT_TOKEN_MAX capped at 32k, compaction fires at 168k (84%). With Copilot overhead it feels closer to 75%. The only available knob OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX also caps actual output length — not a compaction-only setting. I'd love a compaction.threshold percentage config, but that's already tracked in #11930.

Proposed solution

Make the default compaction prompt more aggressive about preserving specifics. At minimum, instruct the compaction LLM to:

  1. Keep exact names, paths, values, error messages, URLs, and version numbers — never generalize them.
  2. Reproduce key parts of user-pasted content verbatim instead of summarizing.
  3. Preserve all user-stated behavioral constraints and preferences.
  4. Preserve debugging state: what was tried, what was ruled out, what evidence was found.

Workaround

The experimental.session.compacting plugin hook can fully replace the compaction prompt today:

// ~/.config/opencode/plugins/better-compaction.ts
export const BetterCompactionPlugin = async (ctx) => {
  return {
    "experimental.session.compacting": async (input, output) => {
      output.prompt = `You are compacting a conversation to allow it to continue in a new context window. Your job is to produce a continuation prompt that preserves ALL information needed to seamlessly resume the work.

CRITICAL RULES:
1. NEVER generalize or summarize away specific details. Keep exact names, paths, values, error messages, flag names, config keys, URLs, and version numbers.
2. If the user pasted external content (conversation logs, error output, code snippets, config files), reproduce the KEY PARTS verbatim.
3. Preserve ALL user-stated constraints, preferences, and instructions.
4. Preserve the investigation/debugging state: what hypotheses were tested, what was ruled out with what evidence.
5. Preserve emotional context and communication style preferences.

Use this template:
---
## Goal
[Specific goal(s)]

## Instructions
- [User instructions, behavioral constraints, communication preferences]

## Discoveries
[Exact technical details: config values, paths, flag names, versions, what was tried and what happened]

## User-Pasted Content
[Verbatim key parts of any content the user pasted]

## Accomplished
### ✅ Completed
[Specific completed work]
### ❌ Not Solved
[Unsolved items with investigation state]
### ⏭️ Next Steps
[Planned next actions]

## Relevant files / directories
[Files read/modified/created, with key external references]
---`
    },
  }
}

System info

  • OS: macOS 15 (Tahoe), Apple M3 Pro arm64
  • OpenCode: v1.2.16
  • Provider: GitHub Copilot (via antigravity-auth plugin)
  • Model: claude-opus-4-6 (200k context, 128k output)

Related issues

  • Feature: Configurable compaction threshold and model (global + per-model) #11930 — Configurable compaction threshold (covers the threshold part of this issue)
  • Bug: compaction.reserved config is ignored for models without explicit 'input' limit #13980 — compaction.reserved ignored in else branch
  • Compaction loses entire conversation #14368 — Compaction loses entire conversation (broader scope, this issue focuses specifically on prompt quality)
Reacted by Henrik Lia, SaladDay, Ryu, vii33, Helliton Soares Mesquita and Kael

Activity

  1. github-actions
    assigned
    thdxr
    on Mar 7, 2026
  2. github-actions
    added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    needs:complianceThis means the issue will auto-close after 2 hours.
    on Mar 7, 2026
  3. lazyalex616
    changed the title [-]Compaction is mandatory for Copilot users but triggers too early and loses critical context[/-] [+][FEATURE]: Improve compaction prompt to preserve critical context details[/+] on Mar 7, 2026
  4. github-actions
    removed
    needs:complianceThis means the issue will auto-close after 2 hours.
    on Mar 7, 2026
  5. github-actions commented on Mar 7, 2026

    @github-actions
    github-actionsBot
    on Mar 7, 2026 – with GitHub Actions
    Contributor
    More actions

    Thanks for updating the issue! It now follows the contributing guidelines and looks good. We appreciate the detailed write-up and the workaround you shared.

  6. nexxeln
    assigned
    nexxeln
    and unassigned
    thdxr
    on Mar 8, 2026
  7. LackesLab commented on Apr 9, 2026

    @LackesLab
    LackesLab
    on Apr 9, 2026
    More actions

    Any news with respect to this? I am running into the same issues with a complete context loss. Opencode switches languages, looses the plot and so on. Anything we can provide further?

    Reacted by GrgaPalcic
  8. thdxr
    removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  9. spaceemotion commented on May 6, 2026

    @spaceemotion
    spaceemotion
    on May 6, 2026
    More actions

    I tried to use this as a workaround for #25746 - but for some reason the compaction still looks the same as before?

    It keeps hallucinating next steps, and the goal always is a single sentence, even though I tried to have it be a full paragraph in my custom prompt.

  10. github-actions commented on Jul 8, 2026

    @github-actions
    github-actionsBot
    on Jul 8, 2026 – with GitHub Actions
    Contributor
    More actions

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  11. github-actions
    closed this as not plannedon Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @nexxeln
    nexxeln

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.