OpenProgram Docs

Request building

How the Context is assembled belongs upstream. Adding a provider touches only this layer and its provider.json.

Context { system_prompt, messages, tools }  --model.api-->  provider translation  -->  wire request

Translation

StyleSystemConversationTools
anthropic-messagesstandalone systemmessagestools, strict inside the tool
openai-completionssystem or developer message at messages[0]messagestools, strict is a boolean
openai-responses, codexinstructionsinputtools
google (gemini)systemInstruction; assistant becomes modelcontents, content is partstools
bedrockstandalone systemmessagestools

Translation also smooths thinking-block signatures, tool arguments as objects or strings, and tool schema dialects (strict, additionalProperties).

Caching

ModeMechanismDeclared by
explicitBreakpoints in the request (cache_control, cachePoint)anthropic, amazon_bedrock
autoAutomatic prefix caching, optional prompt_cache_keyopenai_responses
out_of_bandA separate API stores the cache; hit stats onlyrecognised mode; none declares it
noneNothingevery other provider, by default

Each provider declares this under the cache key of provider.json; a standalone cache.json still loads with a deprecation warning. settings/cache_spec.py: get_cache_spec, cache_mode, ttl_for_retention, cache_key_param, with_lifetime_setting.

{ "mode": "explicit", "breakpoint_format": "cache_control",
  "retention_ttl_map": {"short": null, "long": "1h"},
  "long_ttl_endpoints": ["api.anthropic.com"], "max_breakpoints": 4 }
{ "mode": "auto", "cache_key_param": "prompt_cache_key" }

Breakpoints

RuleDetail
Caller markscache_control on a content block passes through verbatim; Tool.cache_control likewise (passthrough plan)
Unmarkedapply_cache_policy (settings/cache_policy.py) marks the last tool not sent with defer_loading and the latest user message's last text block, else its last block; caller markers stay
Budgetmax_breakpoints (4), spent tools first, then messages
TTL≥ 3600 s is 1h, else the provider default of 5 min; models.prompt_cache_ttl set to 1h makes a plain cache live an hour
SystemOne string, so each provider's _build_system marks the whole block; the policy covers tools and messages
Anthropicstream_simple applies the policy before building; _get_cache_control reads the TTL map and long_ttl_endpoints
Bedrockexplicit but with its own cachePoint blocks and last-message logic, outside apply_cache_policy

The policy follows opencode's cache-policy.ts and protocols/utils/cache.ts. opencode marks a last system segment too, because its system prompt is an array. No Context-level structure is added.

Last updated · 2026-11-25