Skip to content

After /compact, mark the new prefix as an explicit cache breakpoint instead of relying on implicit caching (GPT-5.6+) #44727

Closed as not planned

Description

@hakandamar

Description

Problem

GPT-5.6+ supports explicit prompt caching: setting prompt_cache_options.mode: "explicit" plus a prompt_cache_breakpoint on a specific content block lets the client control exactly where the reusable prefix ends, instead of relying on OpenAI's default implicit mode (which auto-caches the latest message prefix and can trigger unnecessary writes whenever the suffix changes).

Right after a /compact, OpenCode produces a brand-new stable prefix (system prompt + compact summary), which is inherently a cache miss on the next request. That's expected and fine as a one-time cost. But without an explicit breakpoint at that exact boundary, there's nothing telling the API "this is the stable part, stop here" — so the boundary between the stable summary and the growing suffix isn't pinned, and the cache-write cost (billed at 1.25x normal input) risks being paid again on later turns instead of being paid once and then read cheaply (90% discount) for the rest of the session.

Related: #43689 shows OpenCode currently doesn't even send prompt_cache_key, so GPT-5.6 caching may not be engaging reliably at all right now. This issue is about a follow-up/adjacent gap: once caching is wired up, the compact boundary specifically needs an explicit breakpoint so the one-time post-compact cache write doesn't repeat on every subsequent turn.

Impact

Every compact event on a GPT-5.6+ session pays a cache-write premium on the full new prefix (often 50K-150K+ tokens depending on system prompt/tool schema/summary size). If that boundary isn't pinned explicitly, this cost can recur across turns instead of being paid once, which adds up over long sessions with multiple compactions.

Expected behavior

When compaction produces a new context, the boundary right after the stable prefix (system prompt + summary) should be sent with prompt_cache_options.mode: "explicit" and a prompt_cache_breakpoint on that block, so:

the first post-compact request pays the write cost once, as expected
every following request in that session reads that prefix from cache at the discounted rate instead of rewriting it.

Plugins

No response

OpenCode version

1.18.21

Steps to reproduce

  1. Configure OpenCode with any GPT-5.6 model (Luna, Terra, Sol) via OpenCode Desktop.
  2. Run a session long enough to trigger auto-compact, while watching the cache read/write stats.
  3. When compact fires, OpenCode sends a new system prompt + compact summary as the request body. This shows up as a cache_write for that full token count (expected once).
  4. Continue the session with a few more turns. The cache_write from step 3 is not being reused as a cache_read on subsequent requests — instead of one write followed by cheap reads, cache tokens keep re-appearing as writes.

Screenshot and/or share link

No response

Operating System

macOS 26.6.2

Terminal

Warp

Activity

  1. github-actions commented on Aug 24, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If this is intentionally a separate, narrower issue (explicit breakpoint at the compact boundary specifically), please clarify how it differs from #43249 so maintainers can triage it correctly.

  2. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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

Metadata

Metadata

Assignees

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