Skip to content

feat(compaction): reuse prompt caches during compaction - #103

Merged
mochow13 merged 3 commits into
mainfrom
feat/cache-friendly-compaction
Sep 13, 2026
Merged

mochow13 merged 3 commits into
mainfrom
feat/cache-friendly-compaction

Conversation

@mochow13

@mochow13 mochow13 commented Sep 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • preserve the normal system prompt, conversation history, and tool definitions for manual and automatic compaction requests
  • append compaction guidance as the final user message while rejecting attempted tool calls without execution
  • safely apply only the final summary and clean up incomplete manual and automatic compaction streams
  • enable Anthropic and Bedrock cache controls for one-shot requests
  • add GPT-6 Astra model metadata for OpenAI and Codex

Testing

  • go test ./...
  • go vet ./...
  • git diff --check origin/main...HEAD

Closes #97

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.
@mochow13
mochow13 merged commit f171da3 into main Sep 13, 2026
4 checks passed
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.

Compaction flow should try to leverage KV cache

1 participant