ADK Java 1.16.0, released 30 November 2026, rejects truncated, blocked and thought-only summaries so compaction cannot hide history behind them.
A summary that replaces history must be a real summary
Long agent sessions outgrow the model's context. A common answer is compaction: periodically ask a model to summarise a span of older events, and from then on show the model the summary instead of the span. The Agent Development Kit for Java does this with an LLM-based event summarizer for sliding window compaction, the LlmEventSummarizer class in the com.google.adk.summarizer package.
Compaction rests on one assumption: the summary carries the information the agent needs from the events it hides. When the summarising call fails in an ordinary way, by running out of output tokens, being stopped by a safety filter, or returning only internal reasoning, that assumption breaks. Before ADK Java 1.16.0, such a response could still become the summary. The hidden events stayed in the session, but the model no longer saw them; it saw a truncated sentence, an empty string, or nothing.
ADK Java 1.16.0, released on 30 November 2026, includes a fix titled "skip compaction when the summary is unusable" (commit 6c3381f, authored on 23 November 2026). This guide explains what the fix checks, why each check matters, and how to apply the same rule if you write your own summarizer, in ADK or elsewhere.
What the fix checks
The change adds two filters to the response of the summarising model call. Quoting the comments in the code, it rejects explicit failure reasons, while allowing custom models that omit the reason; and an unusable summary must not hide the history it was meant to replace.
- Finish reason. The response is accepted only if its finish reason is
STOPorFINISH_REASON_UNSPECIFIED, or if it has no finish reason at all.MAX_TOKENS,SAFETYand any other reason are rejected. The code compares reason values rather than mapping them through the known enumeration, because, as its comment notes, that mapping would turn unknown reasons intoFINISH_REASON_UNSPECIFIEDand accept them. - Visible text. The content must contain at least one part that is not marked as a thought and has text that is not blank.
If either check fails, the summarizer returns no event, and no compaction happens for that window. The session keeps showing the model the original events until a later attempt produces a usable summary.
The accompanying test class, CompactionSummaryValidationTest, spells out the cases. Rejected: no parts, empty text, blank text, a thought-only response, a response with only a thought signature, a response with only a tool call, and finish reasons MAX_TOKENS, SAFETY, OTHER and an unknown custom reason. Kept: a visible summary, a thought followed by a summary, an unspecified finish reason, and an absent one.
Worked example: a long help desk session
At Belgavi's Book Store, Tanishka works a help desk session with an ADK agent for most of a day. By the afternoon, the session holds dozens of events: a return request from Jenya for CASE-5307, a label that was sent, a replacement that was out of stock, a refund that was approved instead. Compaction runs when the window fills.
Consider three outcomes of the summarising call:
| Summarising call returns | Before 1.16.0 | From 1.16.0 |
|---|---|---|
| A complete summary, finish reason STOP | compacted | compacted |
| A summary cut off mid-sentence, finish reason MAX_TOKENS | compacted with the partial text | not compacted |
| Only a thought part, no visible text | compacted with no visible summary | not compacted |
In the second row, the partial summary might end before it mentions that the refund replaced the replacement. From then on, the agent's view of CASE-5307 stops at "replacement out of stock", and its next reply to Jenya can offer a replacement that was already refused. Nothing in the session looks wrong; every original event is still stored. The model simply cannot see them.
The rule as code
If you implement your own summarizer, or compact history in another framework, the acceptance rule is small enough to write out. The standalone Java below mirrors the two checks with plain records instead of the GenAI types, so it runs without any dependency.
import java.util.List;
import java.util.Optional;
import java.util.Set;
public class SummaryGuard {
record Part(Optional<String> text, boolean thought) {}
record Response(Optional<String> finishReason, List<Part> parts) {}
static final Set<String> COMPLETE = Set.of("STOP", "FINISH_REASON_UNSPECIFIED");
/** True when a summary may replace the history it summarises. */
static boolean usable(Response r) {
boolean finished = r.finishReason().map(COMPLETE::contains).orElse(true);
boolean visibleText = r.parts().stream()
.anyMatch(p -> !p.thought() && p.text().filter(t -> !t.isBlank()).isPresent());
return finished && visibleText;
}
public static void main(String[] args) {
Part summary = new Part(Optional.of("Jenya asked to return CASE-5307; label sent."), false);
Part thinking = new Part(Optional.of("Let me think about the order..."), true);
System.out.println(usable(new Response(Optional.of("STOP"), List.of(summary)))); // true
System.out.println(usable(new Response(Optional.empty(), List.of(thinking, summary)))); // true
System.out.println(usable(new Response(Optional.of("MAX_TOKENS"), List.of(summary)))); // false
System.out.println(usable(new Response(Optional.of("STOP"), List.of(thinking)))); // false
}
}Run it with java SummaryGuard.java on Java 17 or later. The important design choice is the direction of failure. When in doubt, the guard keeps the original history. A session that compacts late uses more context for a while; a session that compacts with a broken summary silently forgets.
Why this belongs in the framework
A summarising call is an ordinary model call, so it fails in ordinary ways. Output limits are reached on long spans. Safety filters occasionally block text that quotes a customer's complaint. Reasoning models can spend their budget on thoughts. In a single chat turn, these failures are visible: the user sees a truncated or empty answer and asks again. Inside compaction, nobody sees the summary at all. It goes straight into the model's context, and its only observable effect is that the agent later behaves as though it forgot something.
That invisibility is why the check is worth having in the framework rather than leaving it to each application. Most teams that enable compaction never look at individual summaries, and they should not have to in order to avoid the obvious failures. The framework can reject the visibly broken cases cheaply, using information it already has in the response, and leave the harder question of accuracy to the application.
What the guard does not check
The fix makes compaction refuse summaries that are visibly unusable. It does not judge whether a well-formed summary is accurate or complete, and no simple rule can. A summary that ends with STOP and contains confident text can still omit the refund. If compaction matters to your application, consider additional checks of your own:
- Required facts. For structured sessions, extract key facts, such as open case ids and their latest status, deterministically from the events and check that each appears in the summary. Reject the summary, or append the missing facts, if any are absent.
- Length bounds. A summary much shorter than expected for the span it covers is suspicious. Treat it as a signal for review, not a hard rule.
- Provenance. Record which events a summary replaced and which model produced it, so a confusing agent reply can be traced to the compaction that preceded it.
Upgrade notes
- Moving to 1.16.0 requires no configuration change for this fix. Sessions where summarisation fails will compact less often than before, which can increase context use. Watch token counts on long sessions after the upgrade.
- If your summarising model returns a custom finish reason for successful completions, those responses are now rejected. Check what your model returns; a model that omits the reason is still accepted.
- If summaries frequently end with
MAX_TOKENS, the fix will expose it as missing compaction. Give the summarising call a larger output limit or summarise smaller spans.
Failure modes
- Compaction that never succeeds. If every summarising call fails a check, context grows until another limit is hit. Log rejected summaries with their finish reason so the cause is visible.
- Thought-only responses from reasoning models. A model configured to think may spend its output budget on thoughts. The guard rejects the result; the fix is to configure the summarising call so it leaves room for the visible answer.
- Trusting the fix to cover accuracy. It covers form, not content. Keep your own checks for what the summary must say.
Verification
Write tests for your summarizer that mirror the upstream cases: feed it responses with each failure reason, with thought-only and blank content, and with a valid summary, and assert which ones produce a compaction. Then run one long synthetic session end to end and confirm that, after a forced MAX_TOKENS on the summarising call, the agent still answers correctly about an early event.
Primary references: the ADK Java 1.16.0 release notes, published 30 November 2026; commit 6c3381f in the google/adk-java repository, which changes LlmEventSummarizer and adds CompactionSummaryValidationTest.