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 — feat: improve deepseek prompt cache reuse by ChangedenCZD · Pull Request #31867 · anomalyco/opencode

Conversation

@ChangedenCZD

@ChangedenCZD ChangedenCZD commented Jun 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Issue for this PR

Closes #31979

Type of change

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

What does this PR do?

DeepSeek prompt cache reuse was weaker than it should be because the current date was being injected into the system context, which makes the cacheable prompt prefix change over time and across replay/
compaction paths. DeepSeek tool turns also need reasoning state to be replayed more carefully than other providers.

This PR moves the date for DeepSeek out of the system prefix and appends it only to the trailing user message in both the opencode request path and the core session runner path. It also omits the
core/date system-context source for DeepSeek sessions, preserves reasoning_content only for assistant messages that belong to a tool turn, strips reasoning parts from non-tool assistant content, and
avoids applying the generic cache-control path to DeepSeek message transforms.

This works because the reusable prompt prefix now stays stable for DeepSeek while the model still receives the current date at the active user turn boundary. Tool-turn reasoning replay also stays scoped to
the turns that actually need it, which keeps the serialized history closer to DeepSeek's expectations and improves cache reuse instead of invalidating it.

How did you verify your code works?

I ran focused local tests for the files and behaviors touched by this change:

  cd packages/opencode
  bun test test/provider/transform.test.ts test/session/system.test.ts test/session/compaction.test.ts

  cd packages/core
  bun test test/session-runner-message.test.ts test/system-context/index.test.ts

Results:

  • packages/opencode: 317 passed, 1 skipped, 0 failed
  • packages/core: 24 passed, 0 failed

Screenshots / recordings

N/A — this is not a UI change.

Checklist

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Gemorroj and piknockyou reacted with thumbs up emoji piercedr, mejobloggs-cw, xlucn, and piknockyou reacted with heart emoji
All reactions
  • 👍 2 reactions
  • ❤️ 4 reactions
@ChangedenCZD ChangedenCZD changed the title fix: improve deepseek prompt cache reuse feat: improve deepseek prompt cache reuse Jun 11, 2026
@github-actions github-actions Bot added the needs:issue label Jun 11, 2026
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:issue labels Jun 11, 2026
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

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

Based on my search results, here are potentially related PRs:

Potentially Related PRs

  1. fix(cache): improve Anthropic prompt cache hit rate with system split and tool stability #14743 - fix(cache): improve Anthropic prompt cache hit rate with system split and tool stability

    • Similar goal: improving cache hit rates by splitting system context to keep cacheable portions stable
    • Related pattern: separating stable vs. dynamic content for better cache reuse
  2. feat(cache): split system prompt into stable/dynamic blocks for independent caching #27377 - feat(cache): split system prompt into stable/dynamic blocks for independent caching

    • Directly related: addresses the same pattern of splitting prompts to maintain cache stability
    • Could share logic or approach with the DeepSeek improvements
  3. chore(cache): rebase prompt caching updates for #14743 #26875 - chore(cache): rebase prompt caching updates for #14743

    • Related rebasing work for cache improvements
  4. fix(session): preserve model message cache snapshots #31613 - fix(session): preserve model message cache snapshots

    • Recent cache-related change that may intersect with reasoning state and message handling

These PRs address similar cache reuse patterns, particularly around splitting stable/dynamic content to prevent cache invalidation. PR #31867 takes a similar but DeepSeek-specific approach by moving the date injection point.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ChangedenCZD
ChangedenCZD force-pushed the feat/enhance_deepseek branch from ec246aa to 0f7d1ce Compare June 11, 2026 11:49
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jun 11, 2026
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Jun 12, 2026
📊 AI CLI 工具社区动态日报 2026-06-12 litang9/big_model_radar#50
Open
📊 AI CLI 工具社区动态日报 2026-06-12 hehongtao88/big_model_radar#16
Open
@ChangedenCZD
ChangedenCZD force-pushed the feat/enhance_deepseek branch 2 times, most recently from 9d9740c to 110b60b Compare June 15, 2026 02:29
This was referenced Jun 15, 2026
📊 AI CLI 工具社区动态日报 2026-06-15 jasonalang/big_model_radar#91
Open
📊 AI CLI 工具社区动态日报 2026-06-15 litang9/big_model_radar#65
Open
@ChangedenCZD
ChangedenCZD force-pushed the feat/enhance_deepseek branch 2 times, most recently from 1cfb791 to 59a4b6e Compare June 17, 2026 05:47
@github-actions github-actions Bot mentioned this pull request Jun 17, 2026
fix(session): anchor system prompt date to session-start time #32644
Closed
@ChangedenCZD
ChangedenCZD force-pushed the feat/enhance_deepseek branch from 59a4b6e to eb29ecb Compare June 17, 2026 10:52
This was referenced Jun 21, 2026
feat(core): make system prompt immutable after session creation #33241
Closed
feat(core): make system prompt immutable after session creation #33246
Closed
@ChangedenCZD
fix: improve deepseek prompt cache reuse
e00458d
@ChangedenCZD
ChangedenCZD force-pushed the feat/enhance_deepseek branch from eb29ecb to e00458d Compare June 22, 2026 05:47
@github-actions github-actions Bot mentioned this pull request Jun 24, 2026
feat(core): add pinFirstUserTurn compaction option for prefix cache stability #33604
Closed
2 of 6 tasks
@github-actions github-actions Bot mentioned this pull request Jul 22, 2026
fix(opencode): add DeepSeek system prompt #38229
Closed
3 of 6 tasks
randomvariable added a commit to randomvariable/opencode that referenced this pull request Aug 3, 2026
@randomvariable @claude
feat: improve deepseek prompt cache reuse
787a213
Keep the volatile current date out of the cached system prefix for DeepSeek
models (both the V2 runner and V1 path) and instead append it to the
trailing user turn, add SystemContext.omit, and rework DeepSeek reasoning
handling so reasoning_content is only replayed across assistant tool turns
(and caching hints are skipped) — maximizing DeepSeek prompt-prefix cache
reuse.

Ported from anomalyco#31867 (adapted for the Effect layer; the prepare() date test
passes an explicit system prompt since anomalyco#19961 moved system assembly to
callers).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@github-actions github-actions Bot mentioned this pull request Aug 31, 2026
feat(opencode): add cache-preserving compaction #46369
Closed
3 of 6 tasks
iceteaSA added a commit to iceteaSA/opencode that referenced this pull request Sep 23, 2026
@iceteaSA
fix(opencode): use one date mechanism for all providers
8ca1e9a
Drop the DeepSeek-only date omission and trailing-user append from anomalyco#31867. The daily date now rides the shared system-reminder, so DeepSeek no longer has a second path that can bust or double-inject it. Cache-control reuse from anomalyco#31867 stays.
@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thdxr thdxr closed this Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[FEATURE]: improve Deepseek prompt cache reuse

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@ChangedenCZD @thdxr
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.