Repository navigation
perf(runtime): compaction requests share the session's prompt cache (CX2) - #250
Merged
lg2m merged 2 commits intoOct 5, 2026
Conversation
…CX2) The compaction summarizer now sends the system prompt, tool list and reasoning effort of the session's prompt runs, built from the same PromptPrefixKey, so it reads the provider cache those runs wrote instead of a cold, tool-less prefix. Context sources and an output contract are not applied to it. - Between runs: RunCapabilities::summarizer(key) replaces without_tools; the key is derived from the session (depth, purpose, approval mode, delegation depth) to match its prompt runs. - In-run: the summarizer gets the run's live system prompt, tools and full message prefix through the cut, falling back to the run alone when the loop's estimate says it would not fit or the provider just rejected it. - Declared tools are never run. Each call is answered with a rejection (with the turn's replay data), everything written so far is discarded, and a second call turn fails the step closed. No schema, protocol or descriptor change. context_assembly and turn_overhead are within noise. Refs: ENG-992, ENG-995
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
CX2: compaction requests share the session's prompt cache
Spec:
docs/plans/compaction.md§ CX2 · ADR-0056 § 5 · Linear: ENG-995 (plan ENG-992)Stacked on #239: review and merge that first; this PR's base is its branch.
Why
Compaction sent a cold request: no system prompt and no tools. It therefore shared no prefix with the session's prompt runs, and turn-1 cache reads were 0 on 152k–365k-token inputs (CX0 baseline).
What changed
PromptPrefixKey.RunCapabilities::summarizer(key)replaceswithout_tools. The key comes from the session (execution::session_prompt_prefix_key): depth, purpose, approval mode and delegation depth.ProviderProtocol).What is and isn't cached (ADR-0056 § Consequences)
/skillinvocation or an output contract, which are per-run suffixes.How verified
cargo test --workspace: 2 099 passed, 13 ignored.hard_cost_budget_cancels_an_unmetered_looping_childandwall_clock_budget_settles_a_hanging_provider_without_a_final_response.qq-providerprofile: 210 passed.fmtandclippy -D warningsare clean.a_between_run_summarizer_request_extends_the_prompt_request_it_followsone_run_spanning_several_windows…an_in_run_summarizer_keeps_the_session_context_before_its_prompt(fails with the full-prefix path disabled)a_summarizer_run_sends_the_prompt_runs_system_prompt_and_tools_without_context_sourcesa_child_sessions_summarizer_uses_the_childs_own_prompt_prefix(fails with a wrong child key)a_summarizer_that_calls_a_tool_is_answered_once_and_its_reply_text_is_droppeda_rejected_call_turn_after_a_cut_reply_drops_the_abandoned_fragment(fails without the fix)a_summarizer_that_calls_tools_on_two_turns_fails_closedRuntime::summarizeunit tests: rejected-call turn with replay, second call turn, and cut call turnMeasurements (same host, against the CX1 tip)
context_assemblyassemble @ 10 000 archived (A/B/A/B)turn_overheadmedian @ 10 / 100 / 1 000 turns (B/A/B, host under load)Both are within noise. The live cache-read share is measured in CX5.
Compatibility
PROTOCOL_VERSION,DESCRIPTOR_VERSIONand the store schema are unchanged.Follow-ups
RunActivity::Compacting.