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]:config: no setting for prompt-cache TTL (1h) - Internals Support it · Issue #62125 · anomalyco/opencode

[FEATURE]:config: no setting for prompt-cache TTL (1h) - Internals Support it #62125

New issue
Copy link
New issue
Copy link
Closed as duplicate
Closed as duplicate
[FEATURE]:config: no setting for prompt-cache TTL (1h) - Internals Support it#62125
Copy link
Labels
pending closetriaging

Description

@airslashfury
airslashfury
opened on Nov 5, 2026
Issue body actions

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Summary

There is no config setting for the prompt-cache lifetime (TTL). opencode always marks the cache with the endpoint's default 5-minute lifetime. The internals already support a 1-hour cache (ttlSeconds >= 3600 maps to Anthropic ttl: "1h" and Bedrock cachePoint.ttl: "1h"), but nothing in user config reaches it. Long-running lead sessions that sit idle while background subagents work pay a full-context cache rewrite after every 5+ minute pause.

Environment

  • opencode version: v2.1.2
  • OS: Darwin 25.6.0 (darwin arm64)
  • Terminal: TERM_PROGRAM=vscode, TERM=xterm-256color, COLORTERM=truecolor
  • Shell: /bin/zsh
  • Install/channel: latest
  • Active plugins: none found in config

Reproduction

  1. Configure a Claude model behind an Anthropic Messages / Bedrock-backed gateway (@ai-sdk/anthropic, custom baseURL).
  2. Run a long session (200k+ context) that launches background subagents and waits more than 5 minutes for them.
  3. On the next turn, inspect the usage: cache_creation.ephemeral_5m_input_tokens is the full context (a complete rewrite) and ephemeral_1h_input_tokens is 0.
  4. Search the V2 docs (models, providers, config) for a cache TTL setting: only compatibility.cacheFormat exists, and the docs state the default five-minute lifetime is used.

Expected Behavior

A per-model or per-agent setting, for example "cache": { "ttlSeconds": 3600 } (or "ttl": "1h"), that forwards to the existing LLM.CacheHint.ttlSeconds. A per-agent setting lets the primary session use 1 h while subagents, which run continuously, keep 5 m.

Actual Behavior

Always 5 minutes. A direct request through the same gateway with cache_control: {type: "ephemeral", ttl: "1h"} works: the first call reports ephemeral_1h_input_tokens: 5616 and an identical second call reports cache_read_input_tokens: 5616. So the gap is only the missing opencode setting.

Additional Context

Impact, measured from one month of local session history (Claude Opus/Sonnet at list prices: 5 m write 1.25x input, 1 h write 2x, read 0.05x):

  • Primary (lead) session: 10% of turns (343) rewrote 50k+ tokens of cache, 94M tokens in total. 259 of those followed a 5–60 minute idle gap.
  • A replay of that history with a 1 h TTL lowers the lead's cache spend by roughly 30%. For continuously running subagents it is neutral to slightly worse (+5–25%), so a per-agent setting matters.
  • Related: compaction.tail_turns in project config logs "unsupported legacy setting".

Activity

  1. opencodejr commented on Nov 5, 2026

    @opencodejr
    opencodejrBot
    on Nov 5, 2026
    Contributor
    More actions

    Thanks for the detailed report and the cost measurements! I think this is a duplicate of #51109, which asks for the same thing: a configurable prompt-cache TTL so long-running lead sessions keep their cache while background subagents work.

    The setting already exists in v2.2.0 and later (added in #59157), and you're on v2.1.2. After upgrading you can set cache.ttl at provider, model or variant level:

    {
      "providers": {
        "anthropic": {
          "settings": { "cache": { "ttl": "1h" } },
          "models": {
            "claude-opus-5-5": { "variants": [{ "id": "short", "settings": { "cache": { "ttl": "5m" } } }] }
          }
        }
      }
    }

    Agents can select a model variant, so your lead agent can use the 1h default while subagents use the 5m variant. Choosing the TTL automatically by context (primary vs subagent) is discussed in #51109 and #53927.

    Possible duplicates and related issues, ordered from most to least likely:

    • Configurable prompt-cache TTL per agent and per provider/model (opencode.jsonc) #51109: configurable prompt-cache TTL per agent and per provider/model; the same request
    • feat(ai): configurable prompt cache TTL #59157: the merged change that added settings.cache.ttl (in v2.2.0)
    • feat(core): add prompt cache rules #53927: open PR that would pick the cache rule by execution context, e.g. 1h for the primary session and 5m for subagents
    • feat(core): time session warming from the model's cache TTL #60969: merged change that times session cache warming from the model's cache.ttl

    The compaction.tail_turns "unsupported legacy setting" warning is a separate topic. If it matters to you, please open its own issue.

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your request is different.

  2. opencodejr
    added
    pending close
    triaging
    on Nov 5, 2026
  3. airslashfury
    closed this as completedon Nov 5, 2026
  4. opencodejr
    closed this as duplicateon Nov 6, 2026
  5. opencodejr commented on Nov 6, 2026

    @opencodejr
    opencodejrBot
    on Nov 6, 2026
    Contributor
    More actions

    Closing this as a duplicate of #51109, since we haven't heard back in the past day. The cache TTL setting you asked for is in v2.2.0 and later (#59157). After upgrading from v2.1.2, you can set settings.cache.ttl (e.g. "1h") at provider, model or variant level, and point an agent at a variant to give your lead session and your subagents different TTLs. Please follow #51109 and #53927 for choosing the TTL automatically by context. If this is still a problem after upgrading, or your request turns out to be different, reply here and we can reopen it. Thanks again for the detailed 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

    Labels

    pending closetriaging

    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.