feat(compaction): reuse prompt caches during compaction - #103
Merged
Merged
Conversation
Manual /compact previously sent a fresh request with a dedicated system prompt and no tools, so provider prompt caches (KV cache) were missed and the entire history was reprocessed. Send the same system prompt, history, and tool registry as a regular turn, with the compaction instruction appended as the final user message, keeping the request prefix cacheable. Tool calls are rejected with DisableToolCalls while the prompt asks the model to work from the existing history alone. The applied summary now uses only the final assistant text run so pre-tool preamble cannot replace the conversation, and incomplete streams route through the compaction failure path so the UI cannot get stuck mid-compaction.
1.05M context via API, 272K on Codex OAuth; efforts low-max.
Preserve the normal request prefix and tool definitions for automatic compaction while preventing tool execution and recursive compaction. Keep provider cache controls enabled for isolated one-shot requests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Testing
go test ./...go vet ./...git diff --check origin/main...HEADCloses #97