Skip to content

feat(llm): support GPT-5.6 prompt cache new options#36320

Open
AbdoKnbGit wants to merge 1 commit into
anomalyco:devfrom
AbdoKnbGit:gpt56-cache
Open

feat(llm): support GPT-5.6 prompt cache new options#36320
AbdoKnbGit wants to merge 1 commit into
anomalyco:devfrom
AbdoKnbGit:gpt56-cache

Conversation

@AbdoKnbGit

@AbdoKnbGit AbdoKnbGit commented Jul 10, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #36318

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds GPT-5.6 prompt caching support while keeping older OpenAI models on their existing behavior.

For the GPT-5.6 family, including gpt-5.6, gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna, and suffix-style variants like gpt-5.6-fast, opencode now sends OpenAI request-wide prompt cache options:

promptCacheOptions: { mode: implicit, ttl: 30m }

That lowers to OpenAI wire field:

prompt_cache_options: { mode: implicit, ttl: 30m }

The existing prompt_cache_key behavior remains in place. GPT-5.5 and older models do not receive prompt_cache_options, so they keep the old cache behavior.

This also parses cache_write_tokens in OpenAI usage responses so cache writes are counted separately from cached reads and normal input tokens.

OpenAI docs: https://developers.openai.com/api/docs/guides/prompt-caching

How did you verify your code works?

Ran these locally:

  • bun test from packages/llm — all tests pass.
  • bun typecheck from packages/llm — passes.
  • bun test test/session-runner.test.ts from packages/core — all tests pass.
  • bun typecheck from packages/core — passes.
  • bun test --timeout 60000 test/provider/transform.test.ts from packages/opencode — all tests pass.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, there is one related PR that might be worth noting:

Related PR (not a duplicate):

The current PR (36320) is focused on adding GPT-5.6 specific prompt caching support with promptCacheOptions and cache_write_tokens parsing, which is distinct from the earlier caching improvements.

Conclusion: No duplicate PRs found for the GPT-5.6 prompt caching feature. PR #35982 addresses caching improvements more generally but is not a duplicate.

@AbdoKnbGit AbdoKnbGit changed the title feat(llm): support GPT-5.6 prompt caching feat(llm): support GPT-5.6 prompt cache new options Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]:Support GPT-5.6 prompt caching defaults

1 participant