Skip to content

feat(summarization): add ReusePromptCaching option#1132

Merged
mrh997 merged 1 commit into
alpha/10from
feat/mrh/summarize-reuse-prompt-caching
Jul 6, 2026
Merged

feat(summarization): add ReusePromptCaching option#1132
mrh997 merged 1 commit into
alpha/10from
feat/mrh/summarize-reuse-prompt-caching

Conversation

@mrh997

@mrh997 mrh997 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

The summarization middleware always rebuilds a fresh model input ([innerSysInstruction, contextMessages..., userInstruction]) on every trigger, which fully invalidates the main conversation's cached prompt on the provider side. This change adds a ReusePromptCaching option so callers can opt into reusing that cache for the summarize call instead.

API Changes

  1. Added: TypedConfig.ReusePromptCaching bool (and its Config alias). When enabled, the summarization input becomes [sysMsg, userMsg1, assistantMsg1, ..., userInstruction] — the original message history is kept byte-identical and only the user instruction is appended — and the summarize call additionally passes model.WithTools(state.ToolInfos) and, when set, model.WithDeferredTools(state.DeferredToolInfos), so the full tool envelope matches the main conversation's and the cache is preserved. Has no effect when GenModelInput is set.

Key Changes

  1. Because the model still sees the original messages and tools under ReusePromptCaching, there is a small chance it calls a tool instead of producing a summary directly — it's recommended to also configure Retry or Failover when enabling this option.
  2. summarize/runFailover now thread the state's ToolInfos and DeferredToolInfos through to the model options builder so both the primary and failover calls apply the same cache-preserving options.

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (alpha/10@c8af907). Learn more about missing BASE report.

Additional details and impacted files
@@             Coverage Diff             @@
##             alpha/10    #1132   +/-   ##
===========================================
  Coverage            ?   81.67%           
===========================================
  Files               ?      188           
  Lines               ?    30554           
  Branches            ?        0           
===========================================
  Hits                ?    24956           
  Misses              ?     3793           
  Partials            ?     1805           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread adk/middlewares/summarization/summarization.go Outdated
@mrh997 mrh997 force-pushed the feat/mrh/summarize-reuse-prompt-caching branch from f3eb202 to 5f672d4 Compare July 3, 2026 10:22
@mrh997 mrh997 force-pushed the feat/mrh/summarize-reuse-prompt-caching branch from 5f672d4 to 31b3077 Compare July 6, 2026 03:19
Allow the summarization middleware to reuse the main conversation's
cached prompt instead of rebuilding a fresh input, avoiding a full
prompt-cache invalidation on every summarize call.
@mrh997 mrh997 force-pushed the feat/mrh/summarize-reuse-prompt-caching branch from 31b3077 to 67a3c27 Compare July 6, 2026 03:21
@mrh997 mrh997 merged commit 079b991 into alpha/10 Jul 6, 2026
16 checks passed
@mrh997 mrh997 deleted the feat/mrh/summarize-reuse-prompt-caching branch July 6, 2026 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants