Skip to content

Prompt cache misses ~10x higher without prompt_cache_key: ZCode 3.36% vs Codex 0.30% on the same Go endpoint #51580

Closed as not planned

Description

@ykk-deadsd

Description

ZCode 3.14.3 and Codex CLI both hit the same Go endpoint (zen/go/v1, deepseek-v4.1-flash) on my machine. Counting per-request cache hits from logs (Sep 25–27):

  • Codex: 2 misses / 657 requests (0.30%)
  • ZCode (opencode-go-chat channel): 23 / 685 (3.36%)

Miss = cache_read < 5% of input, input > 10k. On the ZCode side a miss is a single request between ~99% hits: cache_read drops to 0/1024/1152 (always multiples of 128) while input is 90k–520k, then recovers on the next request. ZCode sends a stable x-opencode-session (verified: 1225 requests, 22 sessions, no drift), but its body has no cache routing key — only model/messages/max_tokens/reasoning_effort. Codex sends prompt_cache_key (per OpenAI's prompt caching docs).

So it looks like the session header alone isn't enough for sticky cache routing. Does Go use prompt_cache_key when present? If yes, could it be documented next to x-opencode-session in the Go guide? Raw per-request tables available if needed.

Plugins

N/A

OpenCode version

N/A (not the opencode CLI) — ZCode 3.14.3 and Codex CLI v0.157.1

Steps to reproduce

  1. Point both clients at zen/go/v1 on the same machine.
  2. Log input_tokens / cache_read_tokens per request.
  3. Count requests with cache_read < 5% of input (input > 10k): ZCode 23/685, Codex 2/657.

Screenshot and/or share link

opencode提示词缓存路由对照报告-20260927.md

Operating System

windows11

Terminal

No response

Activity

  1. github-actions commented on Sep 27, 2026

    @github-actions
    Contributor

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

  2. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the careful measurements, @ykk-deadsd. A cache miss rate about 10x higher than Codex on the same Go endpoint is a real cost, and the per-request breakdown is very useful.

    How the hosted OpenCode Go service routes requests and uses cache keys is handled by the team that runs it, not by the OpenCode app code in this repository. Support for Go and its usage isn't handled in GitHub issues. Please email [email protected] with your comparison report and the raw per-request tables. If you've already emailed, the team will get to it, especially now that we've seen it here. Please keep API keys, account emails and any account or payment details out of this public issue and put them in the email instead.

    For reference: OpenCode itself sends both the x-opencode-session header and a prompt_cache_key built from the same session ID. The current Go guide only mentions the session header, and says Go recognizes ZCode's native session header. I can't confirm from here which of the two the gateway uses for routing.

    Related reports about Go caching:

    The bot will close this issue in 1 day, since this needs to go through email support.

  3. opencodejr commented on Oct 29, 2026

    @opencodejr
    Contributor

    I'm closing this now, @ykk-deadsd. Questions about how the OpenCode Go service routes requests and uses cache keys, like whether it reads prompt_cache_key, are handled by email rather than in GitHub issues. If this is still open for you, please email [email protected] with your comparison report and the raw per-request tables. Please keep API keys, account emails and any account details out of this public issue. Thanks again for the careful measurements.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions