You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
After /compact, mark the new prefix as an explicit cache breakpoint instead of relying on implicit caching (GPT-5.6+) #44727
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
Configure OpenCode with any GPT-5.6 model (Luna, Terra, Sol) via OpenCode Desktop.
Run a session long enough to trigger auto-compact, while watching the cache read/write stats.
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).
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.
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.
Activity
github-actions commentedon Aug 24, 2026
This issue might be a duplicate of existing issues. Please check:
prompt_cache_keywhile sending a maximally divergent prefix — directly overlaps with the post-compact cache boundary problem described hereprompt_cache_keyfor GPT-5.6+ #43689: Enable OpenAI prompt caching by settingprompt_cache_keyfor GPT-5.6+ — the prerequisite issue this report references; explicit breakpoint placement is a follow-on to getting caching wired up at allIf 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.
thdxr commentedon Oct 11, 2026
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 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊