Reuse cached conversation as prefix for dialog-summary helper#188
Draft
yzx9 wants to merge 1 commit into
Draft
Conversation
_generate_dialog_summary sent a brand-new single-user prompt and discarded the leader's cached conversation, so it got 0 cache reuse. Append a short summary instruction to a snapshot of the leader's _dialog_messages instead, so the conversation prefix is an Anthropic cache hit and only the tail is fresh. Falls back to the legacy re-serialized-steps prompt when no dialog is cached yet. - leader_prompts: factor _SUMMARY_FORMAT_BLOCK (shared by legacy + tail); add make_summary_tail referencing the cached conversation above - leader_multiagent: add LeaderAgent.dialog_messages read-only property (Sequence[TextMessage]) + LeaderDriven._leader_dialog_snapshot(); rewrite _generate_dialog_summary with snapshot-or-fallback - tests: anthropic cache-compat assertion (prefix blocks byte-identical, BP2 relocated onto the tail, exactly-one cache_control across message blocks to guard the 4-breakpoint budget); unit tests for the snapshot primitive and the summary snapshot/fallback paths Phase A of the cache-reuse plan. KB extract (#3) and the live-model validation gate (T3) are intentionally out of this commit. Assisted-by: Claude-Code:GLM-5.2
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.
_generate_dialog_summary sent a brand-new single-user prompt and discarded the leader's cached conversation, so it got 0 cache reuse. Append a short summary instruction to a snapshot of the leader's _dialog_messages instead, so the conversation prefix is an Anthropic cache hit and only the tail is fresh. Falls back to the legacy re-serialized-steps prompt when no dialog is cached yet.
Phase A of the cache-reuse plan. KB extract (#3) and the live-model validation gate (T3) are intentionally out of this commit.