fix(adk): avoid duplicate nested checkpoint payloads - #1232
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1232 +/- ##
==========================================
+ Coverage 83.68% 83.73% +0.04%
==========================================
Files 162 162
Lines 23851 23887 +36
==========================================
+ Hits 19960 20001 +41
+ Misses 2630 2627 -3
+ Partials 1261 1259 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Persist ChatModelAgent checkpoint bytes once in the interrupt state map and reconstruct the deprecated ResumeInfo data view when loading. This prevents checkpoint size from doubling at every nested AgentTool boundary while retaining legacy checkpoint compatibility. Change-Id: I6b1bd4f2961fe8fb259824427a73e7fb0bd01258
shentongmartin
force-pushed
the
fix/agenttool-checkpoint-size
branch
from
August 31, 2026 04:08
c6701be to
26b4c14
Compare
N3kox
approved these changes
Aug 31, 2026
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.
Avoid Exponential AgentTool Checkpoint Growth
Problem
ChatModelAgentcheckpoint bytes were persisted twice byRunner: once as theauthoritative interrupt state and again inside the deprecated
ChatModelAgentInterruptInfo.Dataview.AgentToolembeds a child Runner checkpoint in its parent checkpoint. Repeatingthe duplicate payload at every nested boundary caused checkpoint size to grow
exponentially with depth. Three layers around a 1 MiB payload produced an
8.4 MiB checkpoint.
Solution
Persist the checkpoint bytes only in
InterruptID2State. The serialized legacyview records the interrupt state ID instead of another copy of the bytes.
During load, Runner resolves that ID and reconstructs
ChatModelAgentInterruptInfo.Databefore resume callbacks or agents observe it.Compaction is applied only when the legacy bytes exactly match the root
interrupt state. Custom, mismatched, and unaddressed interrupt data remains
inline and unchanged.
Decisions
The existing gob schema remains additive. Old inline checkpoints continue to
load, while malformed compacted references fail instead of silently resuming
with incomplete state.
Key Insight
For nested
AgentToolexecution, the child Runner checkpoint is already thecanonical state of the AgentTool interrupt. Persisting the same bytes in the
legacy presentation field changes linear checkpoint composition into
approximately twofold growth at every agent level.
Summary
ChatModelAgentInterruptInfo.Dataduring resume避免 AgentTool Checkpoint 随嵌套层级指数膨胀
问题
ChatModelAgent的 checkpoint bytes 会被Runner持久化两次:一份位于权威的interrupt state 中,另一份位于已废弃的
ChatModelAgentInterruptInfo.Data兼容视图中。AgentTool会把 Child Runner checkpoint 嵌入 Parent checkpoint。每层都重复完整payload,导致 checkpoint 大小随嵌套深度指数增长。三层包装 1 MiB payload 时,
checkpoint 会增长到约 8.4 MiB。
方案
checkpoint bytes 只持久化在
InterruptID2State。序列化后的 legacy 视图不再保存第二份 bytes,而是记录对应的 interrupt state ID。加载时,Runner 根据该 ID 恢复
ChatModelAgentInterruptInfo.Data,因此 Resume callback 和 Agent 看到的行为不变。只有当 legacy bytes 与根 interrupt state 完全一致时才会去重。自定义、不一致或
缺少地址的 interrupt data 仍按原方式内联保存。
决策
继续使用可增量兼容的 gob schema。旧的内联 checkpoint 可以正常读取;新的引用
如果缺失或类型错误,则明确失败,避免用不完整状态继续 Resume。
核心认识
在嵌套
AgentTool场景中,Child Runner checkpoint 已经是 AgentTool interrupt 的权威状态。同一份 bytes 再写入 legacy 展示字段,会让原本线性的 checkpoint 组合
变成每经过一层 Agent 都近似翻倍。
总结
ChatModelAgentInterruptInfo.Data