feat(adk): add ChatModelAgentMiddleware constructors for filesystem and reduction packages#749
Merged
shentongmartin merged 1 commit intoalpha/08from Feb 4, 2026
Merged
Conversation
- Add NewChatModelAgentMiddleware in filesystem package with BeforeAgent, WrapInvokableToolCall, and WrapStreamableToolCall methods - Add NewChatModelAgentMiddleware in reduction package with BeforeModelRewriteState, WrapInvokableToolCall, and WrapStreamableToolCall methods - Mark old NewMiddleware and NewToolResultMiddleware as deprecated - Add comprehensive tests for the new constructors Change-Id: I299f2736462eb701951faa33e230dc3e4b3a0ee6
1780672 to
aa82cfb
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## alpha/08 #749 +/- ##
===========================================
Coverage ? 80.50%
===========================================
Files ? 135
Lines ? 14031
Branches ? 0
===========================================
Hits ? 11296
Misses ? 1879
Partials ? 856 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
meguminnnnnnnnn
approved these changes
Feb 4, 2026
hi-pender
pushed a commit
that referenced
this pull request
Feb 14, 2026
…nd reduction packages (#749)
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.
Summary
NewMiddlewareandNewToolResultMiddlewarereturnAgentMiddlewarestruct which has limited extensibilityNewChatModelAgentMiddlewareconstructors that returnChatModelAgentMiddlewareinterfaceKey Insight
The
ChatModelAgentMiddlewareinterface provides better context propagation through wrapper methods (WrapInvokableToolCall,WrapStreamableToolCall) compared to the struct-basedAgentMiddleware. The new constructors enable:adk.ChatModelAgentMiddlewareChanges
Filesystem Package
NewChatModelAgentMiddlewarewithBeforeAgent,WrapInvokableToolCall,WrapStreamableToolCallNewMiddlewareas deprecatedReduction Package
NewChatModelAgentMiddlewarewithBeforeModelRewriteState,WrapInvokableToolCall,WrapStreamableToolCallNewToolResultMiddlewareas deprecated概要
NewMiddleware和NewToolResultMiddleware返回AgentMiddleware结构体,扩展性有限NewChatModelAgentMiddleware构造函数,返回ChatModelAgentMiddleware接口关键洞察
ChatModelAgentMiddleware接口通过包装方法(WrapInvokableToolCall、WrapStreamableToolCall)提供了比基于结构体的AgentMiddleware更好的上下文传播能力。新构造函数实现了:adk.ChatModelAgentMiddleware相同的模式变更
Filesystem 包
NewChatModelAgentMiddleware,包含BeforeAgent、WrapInvokableToolCall、WrapStreamableToolCallNewMiddleware标记为已弃用Reduction 包
NewChatModelAgentMiddleware,包含BeforeModelRewriteState、WrapInvokableToolCall、WrapStreamableToolCallNewToolResultMiddleware标记为已弃用