Skip to content

fix(opencode): preserve system prompt cache boundaries#21408

Open
GuestAUser wants to merge 1 commit intoanomalyco:devfrom
GuestAUser:fix/system-prompt-cache-boundary
Open

fix(opencode): preserve system prompt cache boundaries#21408
GuestAUser wants to merge 1 commit intoanomalyco:devfrom
GuestAUser:fix/system-prompt-cache-boundary

Conversation

@GuestAUser
Copy link
Copy Markdown

Issue for this PR

Closes #20110

Type of change

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

What does this PR do?

Keeps the static system prompt header separate from turn-specific system instructions in packages/opencode/src/session/llm.ts.
This lets Anthropic-style prompt caching reuse the stable prefix while preserving the existing collapse-back-to-two-slots behavior after plugin system transforms.

How did you verify your code works?

  • Ran bun test test/session/llm.test.ts
  • Ran bun typecheck
  • Added a request-shape test that checks the outgoing system messages stay split as header + tail

Screenshots / recordings

N/A

Checklist

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

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

Found a related PR:

PR #20109: fix(opencode): keep dynamic user.system separate for prompt caching
#20109

This PR appears to be directly related to the current PR #21408. Both address system prompt handling for Anthropic-style prompt caching. PR #20109 specifically mentions keeping dynamic user.system separate for prompt caching, which is closely aligned with the goal of preserving cache boundaries in the current PR. These may be addressing the same issue (#20110) or complementary aspects of it.

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.

Anthropic prompt caching misses when dynamic user.system is merged into the static prefix

1 participant