OpenHands / OpenHands/software-agent-sdk
feat(llm): investigate Tool search / defer_loading on the Responses path (GPT-5.4+)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 539
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 137
Description
📄 Study page: Tool search (defer_loading) on the OpenHands SDK
Summary
OpenAI's Tool search lets the model load tool definitions on demand instead of sending them all up front, cutting prompt tokens while preserving the prompt cache (loaded tools are appended at the end of the context window). Supported on gpt-5.4+. This issue tracks investigating and supporting it on the SDK's Responses path.
What the feature needs (from the OpenAI docs)
- Add a
{"type": "tool_search"}tool to thetoolsarray. - Mark deferred tools with
defer_loading: true(on functions, on the MCP server tool definition, or on functions inside anamespace). Namespaces/MCP servers are the recommended surface; keep each namespace < ~10 functions. - Two modes:
- Hosted: OpenAI searches the deferred tools declared in the request and returns the loaded subset.
- Client-executed: model emits a
tool_search_call; the app performs lookup and returns atool_search_output(echoingcall_id).
- Advanced:
additional_toolsinput item (roledeveloper) to inject tools at a specific point;namespacetool grouping.
Why it matters for OpenHands
An OpenHands agent typically loads a fat toolset (bash, str_replace_editor, browser, task/delegate, plus one function per MCP tool). Those schemas are re-sent every turn on the Responses path. Deferring rarely-used tools (especially large MCP surfaces) behind tool search could materially cut input tokens without losing capability.
Gaps in the current SDK
- No
defer_loadingflag anywhere;to_responses_tool()always emits the full parameter schema. →openhands-sdk/openhands/sdk/tool/tool.py:497 - No
namespacegrouping and notool_searchtool injection in_prepare_responses_params. →openhands-sdk/openhands/sdk/llm/llm.py:1258 - No parsing/handling of
tool_search_call/tool_search_outputitems, and noadditional_toolsinput support. →openhands-sdk/openhands/sdk/llm/message.py:541,openhands-sdk/openhands/sdk/llm/utils/responses_serialization.py
Proposed scope for a first cut
- Add an opt-in
defer_loadingmarker on tools + optional namespace grouping. - Inject the
tool_searchhosted tool when any deferred tool is present (start with hosted mode; it's the simplest). - Preserve/replay
tool_search_call/tool_search_outputitems forstore=falsecontinuation. - Model-feature gate (
gpt-5.4+).
Notes / open questions
- Depends on LiteLLM passing
defer_loading,namespace, andtool_searchthrough unchanged, and on surfacing the new item types. - Interaction with PTC: deferred tools are not available to a program until loaded; the model must load them before starting a program (see companion PTC issue).
Investigation for GPT‑5.6 feature parity. Companion issues: programmatic tool calling, WebSocket mode, multi-agent.
Companion investigation issues (GPT‑5.6 Responses features): #4082 (Programmatic Tool Calling) · #4083 (Tool search) · #4084 (WebSocket mode) · #4085 (Multi-agent)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the linked Tool search study and inspect to_responses_tool() in openhands-sdk/openhands/sdk/tool/tool.py:497, _prepare_responses_params in openhands-sdk/openhands/sdk/llm/llm.py:1258, and the response item handling in message.py:541 and responses_serialization.py. Done means the Responses path supports the proposed hosted-mode deferred tools, feature gating, and preservation of tool_search_call/tool_search_output for store=false continuation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100