Repository navigation
Description
Title
Add built-in tool_search tool with pluggable search strategies and provider compatibility
Summary
Sending every tool definition on every request consumes context and reduces tool-selection accuracy as catalogs grow. Support large tool catalogs by exposing a built-in tool_search tool that lets the model discover tools on demand. Tool discovery should be provider-independent in core, with provider-specific adapters for OpenAI Responses client-executed tool search and Anthropic custom client-side tool search.
Proposal
Core: built-in tool and strategy
Add a concrete ToolSearchTool with a stable model-facing contract:
- Tool name:
tool_search - Parameters:
query(required),limit(optional) - Read-only and safe to auto-allow in exploration-style permission modes
- Returns discovered tool references/names; it must not execute discovered tools or bypass their normal permission checks
Add a narrow provider-independent strategy interface:
public interface ToolSearchStrategy {
Mono<ToolSearchResult> search(ToolSearchRequest request);
}
public record ToolSearchRequest(
List<ToolSchema> candidates,
List<Msg> recentMessages,
String query,
int limit) {}
public record ToolSearchResult(
List<String> toolNames,
String resultText,
Map<String, Object> metadata) {}Provide a dependency-free default strategy. Custom strategies should be able to use vector search, remote indexes, Jev, or OpenAI Decisions without changing the core tool contract.
Progressive disclosure
Add a tool-search orchestration layer, likely middleware, that:
- Initially exposes only
tool_searchplus always-visible tools. - Executes the selected strategy when the model calls
tool_search. - Accumulates discovered tools for subsequent model calls.
- Keeps per-session state in
RuntimeContext/agent state, not shared agent fields. - Leaves execution and permission checks for discovered tools unchanged.
Provider (OpenAI / Anthropic) compatibility
- https://developers.openai.com/api/docs/guides/tools-tool-search#client-executed-tool-search
- https://platform.claude.com/docs/zh-CN/agents-and-tools/tool-use/tool-search-tool
Activity
iluv7 commentedon Oct 17, 2026
Hi, @jujn, I'm interested in this feature and would like to work on it. I've previously researched the tool-loading strategies used by both OpenAI and Anthropic, and I'd like to bring on-demand tool discovery and loading to AgentScope Java through this issue.
My initial implementation plan is:
tool_searchtool withqueryand optionallimit, following the proposal. Decouple the search algorithm throughToolSearchStrategy, starting with a dependency-free keyword-matching implementation while allowing vector search, remote indexes, and other strategies to be plugged in later.RuntimeContextor agent state.tool_search_callandtool_search_outputfor OpenAI Responses, anddefer_loadingplustool_referenceresults from custom search for Anthropic. Keep the search strategy independent, with protocol conversion handled by provider-specific adapters.I plan to first get the core search and on-demand loading flow working, then complete the adapters for both providers. Does this direction fit the intended scope? If so, could you assign this issue to me?
birdie7761 commentedon Oct 20, 2026
看过Pi的toolSearch,它的设计目前是没有支持有模型侧的native支持的,OpenAI / Anthropic的新协议都是有考虑native支持,有模型的native支持内置工具的schema都不需要传递和出现在上下文中,而且现在看起来内置工具越来越多,是否要留口子与模型配对使用呢?
iluv7 commentedon Oct 20, 2026
嗯呢,这块会留扩展点,搜索逻辑和 provider 的工具加载分开处理,支持走 OpenAI / Anthropic 的原生协议,不会只做动态追加 tools。
feat(tool): add on-demand tool search with native provider loading (#…