Summary
Anthropic prompt caching misses when OpenCode merges the session-static system prompt with per-turn user.system content before the request is built.
Problem
packages/opencode/src/session/llm.ts currently joins the static OpenCode system prefix with dynamic caller-provided user.system text into one system message. For Anthropic-style caching, that makes the cached system prefix change on every follow-up turn.
Expected behavior
The static OpenCode prefix should stay in its own system message so it can remain cache-stable across turns, while dynamic user.system content can vary independently.
Scope
A minimal fix would keep the static prefix as the first system message, move dynamic user.system content into a second system message, and keep plugin-added system fragments collapsed back into the trailing slot.
Summary
Anthropic prompt caching misses when OpenCode merges the session-static system prompt with per-turn
user.systemcontent before the request is built.Problem
packages/opencode/src/session/llm.tscurrently joins the static OpenCode system prefix with dynamic caller-provideduser.systemtext into one system message. For Anthropic-style caching, that makes the cached system prefix change on every follow-up turn.Expected behavior
The static OpenCode prefix should stay in its own system message so it can remain cache-stable across turns, while dynamic
user.systemcontent can vary independently.Scope
A minimal fix would keep the static prefix as the first system message, move dynamic
user.systemcontent into a second system message, and keep plugin-added system fragments collapsed back into the trailing slot.