Skip to content

Review's system text is missing from compaction and warming requests, which breaks prompt caching #53

Closed

Description

@rzane

What happened

On OpenCode 2, the review plugin adds its guidance to the system prompt using only the context hook (index.ts#L312). Compaction and session warming build their requests through the compaction and generate hooks, so their system prompt is different and they miss the prompt cache. OpenCode fixed the same problem in its own plugins in anomalyco/opencode#48749.

Registering the same handler on all three hooks fixes it:

await ctx.session.hook("context", addSystem)
await ctx.session.hook("compaction", addSystem)
await ctx.session.hook("generate", addSystem)

Steps to reproduce

Use ctrl+p and enable "Developer tools". In the developer menu, enable "Tools > Turn token usage".

  1. Enable "warming": true in opencode.json
  2. Send a large prompt, then wait 9 minutes. I used a model with a 5 minute cache TTL.
  3. Send another prompt. Most of the conversation is written to the cache again instead of being read from it.

Versions

@opencode-cockpit/review 0.11.1 · OpenCode 2.1.3 · macOS 26.7.1

Daemon log


Activity

  1. Codestz commented on Oct 31, 2026

    @Codestz
    Owner

    Thank you so much for this report @rzane, it's honestly one of the best I've received: a clear diagnosis, a pointer to the upstream fix, the exact patch, and steps to reproduce. That made this really easy. Sorry for the late answer. I got on it as soon as I saw it.

    It's fixed in 0.11.2, which is out now (#54). Your diagnosis was spot on. It also went further than Review: Shell and Trail add system text the same way, so all three now register the handler on context, compaction and generate.

    To be sure it actually fixes the cache miss, I tested it on OpenCode 2 with a small observer plugin. It logs each request's system block after every hook has run. I sent a prompt, then compacted the session:

    primary request compaction request
    0.11.1 9 parts 4 parts, different hash
    0.11.2 9 parts 9 parts, identical hash

    Compaction and warming now send the same system prefix as the conversation, so they should read from the cache instead of writing it again.

    Update with opencode plugin add @opencode-cockpit/review@0.11.2, or let the updater pick it up. If you still see cache writes after a warm-up, please reopen this and I'll take another look. Thanks again! 🙏

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions