Thinking, compaction, caching¶
These map directly onto ADK features. The package gives each a short setting.
Thinking¶
from adk_agent_harness import ThinkingConfig
app = create_deep_agent(
...,
thinking=ThinkingConfig(include_thoughts=True, thinking_budget=2048),
)
thinking=True uses the model's defaults. ThinkingConfig maps to ADK's
BuiltInPlanner:
include_thoughts=Trueasks the model to return thought summaries. They arrive as event parts withpart.thought == True, so a UI can show reasoning.thinking_budgetcaps thinking tokens.
Prebuilt subagents take the same values through SubAgentSpec.thinking.
Spawned subagents don't set thinking.
Compaction¶
Long sessions eventually outgrow the context window. Compaction summarizes older history once the prompt gets large:
from adk_agent_harness import CompactionConfig
app = create_deep_agent(
...,
compaction=CompactionConfig(token_threshold=100_000, event_retention_size=20),
)
This turns on ADK's event compaction with LlmEventSummarizer, using the root
model and a summary prompt written for long-running work. The summary captures:
- the user's goal and constraints;
- completed actions and results;
- changed files, resources, or outputs;
- outstanding issues;
- the next intended action.
The task ledger lives in session state, outside the conversation, so compaction never loses the plan.
| Field | Default | Meaning |
|---|---|---|
token_threshold |
required | Prompt size, in tokens, that triggers compaction |
event_retention_size |
20 |
Recent events kept verbatim |
compaction_interval |
999 |
ADK's invocation-count trigger; the high default leaves token size in charge |
overlap_size |
0 |
Events shared between compaction windows |
ADK reads the prompt size from the model's reported usage, and falls back to an estimate when a provider doesn't report it.
Context caching¶
from google.adk.agents.context_cache_config import ContextCacheConfig
app = create_deep_agent(..., context_cache=True) # ADK defaults
app = create_deep_agent(..., context_cache=ContextCacheConfig(ttl_seconds=900))
Caching pays off when a long session keeps re-sending a large, stable prefix:
instructions, skills, and tool declarations. The value is passed straight to
App.context_cache_config, and caching is off when you leave it out.