Skip to content

[Bug]: Kiro drops tools loaded by tool_search when the outbound catalog exceeds its budget #2407

Description

@ventianima-lab

Client or integration

Codex App

Area

Tools / MCP / web search

Summary

Kiro routes can successfully complete tool_search, but a function definition returned by that search is omitted again on the immediately following request when the complete client catalog exceeds Kiro's 48-tool or 96 KB outbound budget. The model then reports that the discovered tool is unavailable.

I expected a tool returned by tool_search_output to remain callable on the next Kiro turn. The tool_search gateway itself should also remain available when the initial catalog is oversized.

The parser already marks restored definitions with loadedFromToolSearch: true. The Kiro adapter ignored that marker and retained only the ordinary declaration prefix, so newly loaded definitions appended after the declared tools fell outside the wire budget.

A locally verified fix applies a stable priority order before the existing count and byte limits:

  1. definitions marked loadedFromToolSearch
  2. the toolSearch gateway
  3. ordinary declarations in caller order

This keeps deterministic order inside each tier and preserves the existing fail-closed limits.

Reproduction

  1. Start OpenCodex 2.31.0 and route a Codex App task to kiro/claude-opus-5.
  2. Send a Responses request with more than 48 effective tools (or a converted catalog larger than 96 KB).
  3. Include a prior client-executed tool_search_call and a completed tool_search_output returning a function such as codex_app__send_message_to_thread.
  4. On the continuation, ask the model to invoke the returned function.
  5. Observe that src/responses/parser.ts restores the definition and sets loadedFromToolSearch: true, but convertKiroToolContext sends only the ordinary prefix. The returned function is named in the Kiro omission notice and the model says it cannot call it.

Minimal effective catalog shape:

{
  "model": "kiro/claude-opus-5",
  "input": [
    {"type":"tool_search_call","call_id":"call_search","execution":"client","arguments":{"query":"send message to task"}},
    {"type":"tool_search_output","call_id":"call_search","status":"completed","execution":"client","tools":[{"type":"function","name":"codex_app__send_message_to_thread","description":"Send a message to a task","parameters":{"type":"object"}}]}
  ],
  "tools": [
    {"type":"tool_search","description":"Search deferred tools"},
    "48 or more ordinary function declarations"
  ],
  "parallel_tool_calls": false
}

After prioritizing loaded/search definitions, a regression case with 68 ordinary functions plus tool_search and one loaded function sends exactly 48 client tools, keeps the loaded function first and search gateway second, and preserves ordinary relative order. A live local Responses call with 70 effective tools returned a function_call for codex_app__send_message_to_thread.

Version

2.31.0 (source baseline commit 6ae83b1f189c353935d4977bb01227484fbdb52b)

Operating system

Microsoft Windows 11 Pro, version 10.0.26200, build 26200

Provider and model

Kiro / claude-opus-5

Logs or error output

[opencodex] Kiro's outbound catalog budget allows 48 of 70 client tools this turn. Omitted and unavailable this turn: codex_app__send_message_to_thread, ...

After the fix, the same live request completes with:

status: completed
output type: function_call
name: codex_app__send_message_to_thread

Focused Kiro adapter suite: 55 passed, 0 failed. TypeScript typecheck: passed.

Screenshots and supporting files

No screenshot is required. The reproduction is request-shape deterministic and is covered by a focused adapter regression test.

Redacted configuration

{
  "provider": "kiro",
  "adapter": "kiro",
  "authMode": "key",
  "apiKey": "[REDACTED]"
}

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcatalogModel catalog, slugs, visibility, routed entriestoolstool_calls, MCP, web-search / sidecar tools

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions