feat(adk): reduction mw support tool_call & tool_resp messages rewrite - #956
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #956 +/- ##
==========================================
+ Coverage 82.87% 82.89% +0.01%
==========================================
Files 148 148
Lines 16740 16788 +48
==========================================
+ Hits 13874 13916 +42
- Misses 1904 1911 +7
+ Partials 962 961 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
N3kox
force-pushed
the
feat/clear_tool_call
branch
2 times, most recently
from
April 13, 2026 13:53
ea8f6d6 to
607ee0b
Compare
N3kox
marked this pull request as ready for review
April 14, 2026 03:07
mrh997
reviewed
Apr 14, 2026
mrh997
reviewed
Apr 27, 2026
N3kox
force-pushed
the
feat/clear_tool_call
branch
from
April 27, 2026 12:50
607ee0b to
264800f
Compare
mrh997
reviewed
Apr 27, 2026
| rewritten = append(rewritten, rewrittenMessages...) | ||
| i = trEnd | ||
| default: // unexpected | ||
| i++ |
N3kox
force-pushed
the
feat/clear_tool_call
branch
2 times, most recently
from
April 27, 2026 13:06
50d1292 to
bdcb895
Compare
N3kox
force-pushed
the
feat/clear_tool_call
branch
from
April 27, 2026 13:17
bdcb895 to
c7ccebc
Compare
mrh997
approved these changes
Apr 27, 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.
What type of PR is this?
feat
Check the PR title.
(Optional) Translate the PR title into Chinese.
feat(adk/reduction): 新增 ClearRewriteMessagesHandler 功能,支持工具调用 / 工具返回消息消息重写
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en:
This PR adds a new
ClearRewriteMessagesHandlerto the reduction middleware, allowing users to rewrite assistant and tool message pairs through this preprocessing step before actual tool cleanup.Since directly removing parameters of certain tool calls (such as write_file/edit_file) may cause hallucination, rewriting them as user messages can both retain the tool call records and remove a large amount of content context.
zh(optional):
本 PR 为 reduction 中间件新增了
ClearRewriteMessagesHandler功能,允许用户在实际的工具清理前,通过这个预处理环节重写助手和工具消息对。由于直接移除某些工具调用(如 write_file/edit_file)的参数可能导致幻觉,此时将其重写为 user 消息既可以保留工具调用记录,又可以移除大量的 content 上下文。
(Optional) Which issue(s) this PR fixes:
(optional) The PR that updates user documentation: