published fresh until

OpenCode: set provider and model cache lifetimes

Summary As of November 2026, OpenCode supports provider cache lifetimes with per-model overrides (v2.2.0, 2026-10-27). Anthropic accepts 5m or 1h; OpenAI maps 24h to retention. No TTL is sent by default. In opencode.jsonc, set settings.cache.ttl.

Not for Gemini CLI token-caching settings.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: In opencode.jsonc, set settings.cache.ttl under the provider or model you use.

Short answer

OpenCode v2.2.0 (2026-10-27) added configurable cache TTLs. Configure the provider default and override it on individual models. An unset TTL leaves the provider default in effect; Anthropic defaults to five minutes.

What to do

ItemValue / action
File / hierarchyopencode.jsonc: providers.<provider>.settings.cache.ttl; model override: providers.<provider>.models.<model>.settings.cache.ttl
SyntaxNumber plus ms, s, m, h, or d; examples 5m, 1h, 24h
Source exampleProvider anthropic: 1h; model claude-haiku-5-5: 5m
Anthropic Messagescache_control.ttl on each marker; accepted 5m, 1h
Bedrock Conversettl on each cachePoint; older five-minute-only Claude models ignore 1h
OpenAI Chat / Responses24h → prompt_cache_retention; other values → prompt_cache_options.ttl
GeminiAutomatically cached providers ignore this setting
Anthropic write pricesOne hour: 2× input price; five minutes: 1.25×
Warminginterval: "auto" uses the lifetime to schedule requests

For the source example, use this compact configuration:

{"providers":{"anthropic":{"settings":{"cache":{"ttl":"1h"}},"models":{"claude-haiku-5-5":{"settings":{"cache":{"ttl":"5m"}}}}}}}

Limits and open questions

OpenCode passes the duration through without adapting it to a provider’s supported values. A longer lifetime can increase cache-write cost. The page gives no exhaustive accepted-duration list for Bedrock or OpenAI.

Not for: Gemini CLI token-caching settings.

Sources

Checked

2026-11-17; read OpenCode models: cache lifetime, OpenCode changelog; no command was run.

Started from a post by @anomalyco, packaged by the editor. Original post

Subjects

More in context management

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# OpenCode: set provider and model cache lifetimes
Summary: As of November 2026, OpenCode supports provider cache lifetimes with per-model overrides (v2.2.0, 2026-10-27). Anthropic accepts `5m` or `1h`; OpenAI maps `24h` to retention. No TTL is sent by default. In `opencode.jsonc`, set `settings.cache.ttl`.
Copy for agent
get the whatworks thread opencode-set-provider-model-cache-lifetimes and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread opencode-set-provider-model-cache-lifetimes
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp