Allow configuring the default tool_search result limit

Open 💬 0 comments Opened Jul 5, 2026 by Asunfly

Summary

Please add a user/team configurable default result limit for tool_search.

Today the model can pass an explicit limit per tool_search call, but the default used when limit is omitted is fixed in code:

  • codex-rs/tools/src/tool_discovery.rs: TOOL_SEARCH_DEFAULT_LIMIT: usize = 8
  • codex-rs/core/src/tools/handlers/tool_search.rs: args.limit.unwrap_or(TOOL_SEARCH_DEFAULT_LIMIT)

I could not find a config.toml / schema key that lets users raise this default. The config schema appears to expose feature booleans such as tool_search and tool_search_always_defer_mcp_tools, but no default-limit setting.

Why this matters

For MCP-heavy or plugin-heavy setups, eight results is often too small for reliable discovery. Users and agent instructions can say "use limit >= 20 when searching for tools", but that depends on the model remembering to set the optional argument on every search.

When the model omits limit, the fixed default can hide relevant tools and cause the assistant to conclude a capability is unavailable. This is especially painful for operational workflows where the correct tool is present but buried behind other deferred tool metadata.

This is not asking to remove the per-call limit; it is asking for a durable default so users/admins can make high-recall tool discovery the normal behavior for their environment.

Expected behavior

Add a supported configuration surface, for example one of:

[tools]
tool_search_default_limit = 20

or:

[tool_search]
default_limit = 20

The configured value should:

  • apply only when the model omits the per-call limit;
  • continue to respect any explicit per-call limit;
  • be bounded to a reasonable supported range;
  • be visible in the model-facing tool description/default metadata if that description currently mentions the default;
  • work consistently across CLI, desktop/app-server, and other surfaces that use the shared ToolSearchHandler.

Related issues / PRs found before filing

I searched existing openai/codex issues and PRs for tool_search, TOOL_SEARCH_DEFAULT_LIMIT, default limit, default cap, config, and toolSearch limit.

Related but not the same:

  • #17684 adjusted default result caps for selected MCP results while keeping the regular default at 8.
  • #22381 removed the server-specific bucket limit override and restored a single global default path.
  • #30085 improves ranking while preserving requested/default limit semantics.
  • #30104 and #30186 expose debug/inspection APIs where limit can be provided, but do not make the ordinary tool_search default configurable.
  • #21503 covers false negatives from tool_search ranking/limits, but the requested fix there is exact-match ranking, not a configurable default.

I did not find an issue or PR specifically requesting a user/team configurable tool_search default limit.

Additional notes

A config-level default would let teams tune the recall/token tradeoff once instead of encoding brittle prompt instructions such as "always pass limit: 20 to tool search". This would also help agents comply with local operating rules that require wider tool discovery before falling back to less precise mechanisms.

View original on GitHub ↗