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 — fix: add prompt caching to session compaction - Issue #10342 by Luckybalabala · Pull Request #10380 · anomalyco/opencode

Conversation

@Luckybalabala

@Luckybalabala Luckybalabala commented Jan 24, 2026

Copy link
Copy Markdown

Problem

Session compaction sent an empty system: [] array, missing the ~90% cost savings from prompt caching.

Solution

Added system prompts to compaction processor:

import { SystemPrompt } from "./system"

// Changed from:
system: [],

// To:
system: [...(await SystemPrompt.environment()), ...(await SystemPrompt.custom())],

Impact

  • Cost Savings: Enables ~90% reduction in compaction API costs through cached system prompts
  • Consistency: Compaction now uses the same system prompts as regular loops

Technical Details

The SystemPrompt.environment() and SystemPrompt.custom() methods return prompts that support Claude's prompt caching feature:

  • Environment prompts (project context, tool definitions, etc.)
  • Custom prompts (user-defined instructions)

Testing

  • Verified with existing test suite (752/759 tests passing)
  • Confirmed system prompts are now included in compaction requests

Fixes #10342 - Major cost optimization for long sessions

Sorry, something went wrong.

Uh oh!

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

Faddz reacted with rocket emoji
All reactions
  • 🚀 1 reaction
@Luckybalabala
Luckybalabala requested a review from adamdotdevin as a code owner January 24, 2026 12:02
@github-actions

github-actions Bot commented Jan 24, 2026

Copy link
Copy Markdown
Contributor

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

Based on my search, I found related PRs that touch on session compaction, but none appear to be direct duplicates of PR #10380:

Related but not duplicates:

  1. PR feat(compaction): Hybrid compaction pipeline with deterministic extraction + LLM #7104 - feat(compaction): Hybrid compaction pipeline with deterministic extraction + LLM

    • Related to compaction logic but focuses on a different approach (hybrid pipeline)
  2. PR fix(session): prevent context overflow by adding safety margin to compaction check #6562 - fix(session): prevent context overflow by adding safety margin to compaction check

    • Related to session compaction but addresses a different issue (safety margins)
  3. PR Docs: Comprehensive analysis & fix guides for ALL 10 issues (AI-analyzed) #10363 - Docs: Comprehensive analysis & fix guides for ALL 10 issues

    • Documentation PR that may reference issue /compact doesn't utilize prompt caching #10342 but is not a duplicate

Conclusion:
No duplicate PRs found

All reactions

Sorry, something went wrong.

Uh oh!

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

@Luckybalabala
Luckybalabala force-pushed the fix/issue-10342-compaction-prompt-caching branch from 9859412 to 7ff669a Compare January 24, 2026 13:08
root root
fix(opencode): add prompt caching to session compaction - Issue anoma…
73f68a1
…lyco#10342
@Luckybalabala
Luckybalabala force-pushed the fix/issue-10342-compaction-prompt-caching branch from 7ff669a to 73f68a1 Compare January 24, 2026 18:46
@Luckybalabala Luckybalabala closed this Jan 26, 2026
@Luckybalabala
Luckybalabala deleted the fix/issue-10342-compaction-prompt-caching branch January 26, 2026 05:55
@Luckybalabala
Luckybalabala restored the fix/issue-10342-compaction-prompt-caching branch January 26, 2026 06:13
@Luckybalabala Luckybalabala reopened this Jan 26, 2026
@thdxr
thdxr force-pushed the dev branch from cbab81f to 2d3c7a0 Compare January 30, 2026 04:49
@opencode-agent
opencode-agent Bot force-pushed the dev branch from 00637c0 to 71e0ba2 Compare January 30, 2026 14:32
@thdxr
thdxr force-pushed the dev branch 4 times, most recently from f1ae801 to 08fa7f7 Compare January 30, 2026 14:37
@github-actions github-actions Bot mentioned this pull request Jan 31, 2026
fix(opencode): prevent context overflow during compaction #11453
Closed
@github-actions github-actions Bot mentioned this pull request Feb 18, 2026
fix: split system prompt into 2 messages for proper Anthropic prompt caching #14203
Closed
3 of 6 tasks
@bhagirathsinh-vaghela bhagirathsinh-vaghela mentioned this pull request Feb 23, 2026
fix(cache): improve Anthropic prompt cache hit rate with system split and tool stability #14743
Closed
3 tasks done
@github-actions

github-actions Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot closed this Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adamdotdevin adamdotdevin Awaiting requested review from adamdotdevin

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.

/compact doesn't utilize prompt caching

Uh oh!

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

1 participant

@Luckybalabala
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.