Skip to content

feat(agents): upgrade Agent SDK, enable ToolSearch, and add UI renderer#13690

Merged
DeJeune merged 5 commits intomainfrom
DeJeune/sdk-web-search
Mar 22, 2026
Merged

feat(agents): upgrade Agent SDK, enable ToolSearch, and add UI renderer#13690
DeJeune merged 5 commits intomainfrom
DeJeune/sdk-web-search

Conversation

@DeJeune
Copy link
Copy Markdown
Collaborator

@DeJeune DeJeune commented Mar 21, 2026

What this PR does

Before this PR:

  • Agent SDK version 0.2.71 — ToolSearch (deferred MCP tool discovery) was blocked for non-first-party Anthropic API hosts.
  • All MCP tool definitions were loaded into the context window upfront, consuming significant tokens.
  • ToolSearch calls rendered using the generic UnknownToolRenderer fallback.

After this PR:

  • Agent SDK upgraded to 0.2.81 — ToolSearch now works with custom ANTHROPIC_BASE_URL when ENABLE_TOOL_SEARCH is set.
  • ENABLE_TOOL_SEARCH=auto is set in ClaudeCodeService env, enabling on-demand MCP tool discovery.
  • Dedicated ToolSearchTool renderer displays search query and matched results in the agent message stream.
image

Why we need it and why it was done in this way

The following tradeoffs were made:

  • Used auto mode (default threshold) rather than always-on, so ToolSearch only activates when MCP tool definitions are large enough to benefit from deferral.
  • ToolSearch renderer follows the same pattern as SearchTool for consistency.

The following alternatives were considered:

  • Patching the first-party host check manually — upgrading is cleaner since upstream already fixed it.
  • ENABLE_TOOL_SEARCH=trueauto is 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

  • ToolSearch requires Sonnet 4+ or Opus 4+ models (Haiku not supported).
  • The SDK automatically defers MCP tools when their definitions exceed the threshold.
  • i18n keys synced to all locales via pnpm i18n:sync.

Checklist

  • PR: The PR description is expressive enough and will help future contributors
  • Code: Write code that humans can understand and Keep it simple
  • Refactor: Boy Scout Rule
  • Upgrade: Impact of this change on upgrade flows was considered — no breaking changes
  • Documentation: Not required
  • Self-review: Reviewed changes

Release note

Upgrade Agent SDK to 0.2.81, enable ToolSearch for efficient MCP tool discovery, and add dedicated UI renderer for ToolSearch results.

🤖 Generated with Claude Code

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]>
@DeJeune DeJeune requested review from EurFelux and vaayne March 21, 2026 18:36
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]>
@DeJeune DeJeune changed the title chore(deps): upgrade @anthropic-ai/claude-agent-sdk to 0.2.81 feat(agents): upgrade Agent SDK and enable ToolSearch for MCP tool discovery Mar 21, 2026
@DeJeune DeJeune linked an issue Mar 21, 2026 that may be closed by this pull request
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]>
@DeJeune DeJeune changed the title feat(agents): upgrade Agent SDK and enable ToolSearch for MCP tool discovery feat(agents): upgrade Agent SDK, enable ToolSearch, and add UI renderer Mar 21, 2026
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]>
@DeJeune DeJeune force-pushed the DeJeune/sdk-web-search branch from 0ca9be9 to 8b116a0 Compare March 21, 2026 19:35
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]>
@DeJeune DeJeune force-pushed the DeJeune/sdk-web-search branch from 8b116a0 to f3c9ad9 Compare March 21, 2026 19:40
Copy link
Copy Markdown
Collaborator

@vaayne vaayne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Collaborator

@GeorgeDong32 GeorgeDong32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This issue/comment/review was translated by Claude.

Code Review Summary

Overview of Changes

  • Upgrade @anthropic-ai/claude-agent-sdk from 0.2.71 to 0.2.81
  • Enable ENABLE_TOOL_SEARCH=auto environment variable to support delayed discovery of MCP tools
  • Add ToolSearchTool renderer 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 ToolSearchTool component 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 组件补充单元测试

总体评价:变更清晰、实现规范,可以合并。

@DeJeune DeJeune merged commit e2c1d53 into main Mar 22, 2026
10 checks passed
@DeJeune DeJeune deleted the DeJeune/sdk-web-search branch March 22, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Can it support Tool Search for MCP tools?

4 participants