feat(agents): upgrade Agent SDK, enable ToolSearch, and add UI renderer#13690
Merged
feat(agents): upgrade Agent SDK, enable ToolSearch, and add UI renderer#13690
Conversation
Upgrades the Agent SDK from 0.2.71 to 0.2.81. The new version relaxes the first-party host restriction for ToolSearch: setting ENABLE_TOOL_SEARCH now enables deferred tool discovery even with custom ANTHROPIC_BASE_URL. All 3 postinstall patches (spawn→fork, IPC stdio) still apply cleanly. Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: suyao <[email protected]>
Set ENABLE_TOOL_SEARCH=auto in ClaudeCodeService env to enable on-demand MCP tool discovery, reducing context window usage by ~85% when many MCP tools are connected. Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: suyao <[email protected]>
8 tasks
Add a dedicated renderer for the ToolSearch tool in the agent message stream, replacing the generic UnknownToolRenderer fallback. Displays the search query and matched tool results with the same styling as the existing SearchTool component. Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: suyao <[email protected]>
ToolSearch output is an object (not a string), which caused `output.split is not a function` when passed to truncateOutput. Normalize output via JSON.stringify before rendering. Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: suyao <[email protected]>
0ca9be9 to
8b116a0
Compare
ToolSearch output is an array of `{ type: "tool_reference", tool_name }`
objects, not a string. Update the type definition and renderer to parse
tool references and display matched tool names directly instead of
dumping raw JSON.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: suyao <[email protected]>
8b116a0 to
f3c9ad9
Compare
GeorgeDong32
approved these changes
Mar 22, 2026
Collaborator
There was a problem hiding this comment.
Note
This issue/comment/review was translated by Claude.
Code Review Summary
Overview of Changes
- Upgrade
@anthropic-ai/claude-agent-sdkfrom 0.2.71 to 0.2.81 - Enable
ENABLE_TOOL_SEARCH=autoenvironment variable to support delayed discovery of MCP tools - Add
ToolSearchToolrenderer component
Evaluation Results
Code Quality: ✅ Good
- Follows existing tool renderer patterns
- Complete type definitions, using Zod schema for type-safe parsing
- i18n has synchronized all language files
Security: ✅ No issues
Performance: ✅ No issues
- ToolSearch functionality reduces token consumption through lazy loading of MCP tool definitions
CI Status: ✅ All checks passed
Improvement Suggestions (Low Priority)
- Recommend adding unit tests for
ToolSearchToolcomponent in the future
Overall Assessment: Changes are clear, implementation is well-structured, ready to merge.
Original Content
代码审查总结
变更概述
- 升级
@anthropic-ai/claude-agent-sdk从 0.2.71 到 0.2.81 - 启用
ENABLE_TOOL_SEARCH=auto环境变量,支持 MCP 工具延迟发现 - 新增
ToolSearchTool渲染器组件
评估结果
代码质量: ✅ 良好
- 遵循现有工具渲染器模式
- 类型定义完整,使用 Zod schema 进行类型安全解析
- i18n 已同步所有语言文件
安全性: ✅ 无问题
性能: ✅ 无问题
- ToolSearch 功能通过延迟加载 MCP 工具定义减少 token 消耗
CI 状态: ✅ 所有检查通过
改进建议(低优先级)
- 建议后续为
ToolSearchTool组件补充单元测试
总体评价:变更清晰、实现规范,可以合并。
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 this PR does
Before this PR:
UnknownToolRendererfallback.After this PR:
ANTHROPIC_BASE_URLwhenENABLE_TOOL_SEARCHis set.ENABLE_TOOL_SEARCH=autois set inClaudeCodeServiceenv, enabling on-demand MCP tool discovery.ToolSearchToolrenderer displays search query and matched results in the agent message stream.Why we need it and why it was done in this way
The following tradeoffs were made:
automode (default threshold) rather than always-on, so ToolSearch only activates when MCP tool definitions are large enough to benefit from deferral.SearchToolfor consistency.The following alternatives were considered:
ENABLE_TOOL_SEARCH=true—autois more conservative and lets the SDK decide based on tool count.Breaking changes
None. All 3 postinstall patches (spawn→fork, IPC stdio) apply cleanly on the new version.
Special notes for your reviewer
pnpm i18n:sync.Checklist
Release note
🤖 Generated with Claude Code