Skip to content

[Feature]: Support built-in tool_search tool #3622

Closed

Description

@jujn

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:

  1. Initially exposes only tool_search plus always-visible tools.
  2. Executes the selected strategy when the model calls tool_search.
  3. Accumulates discovered tools for subsequent model calls.
  4. Keeps per-session state in RuntimeContext/agent state, not shared agent fields.
  5. Leaves execution and permission checks for discovered tools unchanged.

Provider (OpenAI / Anthropic) compatibility

Activity

  1. added
    enhancement
    help wanted
    on Oct 17, 2026
  2. iluv7 commented on Oct 17, 2026

    @iluv7
    Contributor

    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:

    1. Provide a unified search entry point and strategy interface. Add the built-in tool_search tool with query and optional limit, following the proposal. Decouple the search algorithm through ToolSearchStrategy, starting with a dependency-free keyword-matching implementation while allowing vector search, remote indexes, and other strategies to be plugged in later.
    2. Implement progressive tool disclosure. Initially expose only the search tool and tools configured to remain always visible. Resolve search matches to their full definitions and make them available for subsequent model calls. Accumulate discoveries within the session and deduplicate them by name. Reuse existing middleware extension points where possible, and keep session state in RuntimeContext or agent state.
    3. Adapt to both providers' native protocols. Handle tool_search_call and tool_search_output for OpenAI Responses, and defer_loading plus tool_reference results from custom search for Anthropic. Keep the search strategy independent, with protocol conversion handled by provider-specific adapters.
    4. Preserve existing execution and permission checks. Search should only discover tools; actual execution should continue through the existing invocation flow and permission checks.
    5. Add tests, documentation, and examples. Cover search ranking and limits, empty results, repeated searches, session isolation, permission checks, and provider protocol compatibility. Update both English and Chinese documentation and add a usage example.

    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?

  3. birdie7761 commented on Oct 20, 2026

    @birdie7761
    Contributor

    看过Pi的toolSearch,它的设计目前是没有支持有模型侧的native支持的,OpenAI / Anthropic的新协议都是有考虑native支持,有模型的native支持内置工具的schema都不需要传递和出现在上下文中,而且现在看起来内置工具越来越多,是否要留口子与模型配对使用呢?

  4. iluv7 commented on Oct 20, 2026

    @iluv7
    Contributor

    嗯呢,这块会留扩展点,搜索逻辑和 provider 的工具加载分开处理,支持走 OpenAI / Anthropic 的原生协议,不会只做动态追加 tools。

  5. added a commit that references this issue on Oct 28, 2026
    4b6c59a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementhelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions