Skip to content

feat(providers): strip named hosted tools only beside client tools - #8499

Merged
lidge-jun merged 2 commits into
devfrom
codex/8204-conditional-hosted-tools
Nov 10, 2026
Merged

lidge-jun merged 2 commits into
devfrom
codex/8204-conditional-hosted-tools

Conversation

@lidge-jun

Copy link
Copy Markdown
Owner

Summary

Some Gemini-backed Responses gateways accept hosted web_search alone and function calling alone, but answer HTTP 400 when one request carries both (Please enable tool_config.include_server_side_tool_invocations to use Built-in tools with Function calling.). The only workaround was unsupportedHostedTools: ["web_search"], which also removes the search-only capability the gateway serves.

This adds the opt-in provider field the owner chose on #8204:

  • unsupportedHostedToolsWithClientTools (same closed vocabulary and alias expansion as unsupportedHostedTools) strips the named hosted declarations only when the same request declares a client tool: a function or custom tool, or a namespace with members, in tools, a client-loaded additional_tools catalog, or a tool_search_output result. A request that declares only hosted tools keeps them.
  • The conditional list joins the same alias-expanded set stripUnsupportedHostedTools already uses (src/responses/hosted-tool-policy.ts, src/adapters/openai-responses/tool-schema.ts). tools, additional_tools, tool_choice and allowed_tools reconciliation therefore run through the same code as the unconditional list. A forced selector for a removed tool becomes "none" exactly as before.
  • unsupportedHostedTools stays authoritative. With the new field unset or [], the request is unchanged and the client-tool scan never runs.
  • Config schema (shared hosted-tool list validator), management PATCH/GET, the editor field policy, and the provider-rename roster know the field.
  • Carry-over fix found on the way: a same-destination dashboard save (POST /api/providers with an existing name) dropped the stored unsupportedHostedTools, confirmed with a fail-first probe on unmodified dev. Both hosted-tool lists now travel with the other upstream-behavior fields in PROVIDER_COMPAT_CARRY_FIELDS. Carrying only the new list would let a hosted-only request forward a tool the dropped unconditional list had denied. This changes save behavior for the existing field: it now survives an edit that omits it, like the other eleven carried fields.
  • Docs: a new provider-reference row; the "What a provider save keeps" section now names thirteen fields in English and all seven translations (it previously said eleven in one place and ten in another). Structure: structure/chat-compat.md was at 599/600 lines, so its hosted-tool section moved unchanged into a new structure/providers/hosted-tool-denials.md (manifest and INDEX.md regenerated).

Closes #8204

Verification

  • Fail-first on unmodified dev: tests/responses/responses-hosted-tool-conditional.test.ts 7 pass / 8 fail (mixed request strips; function/custom/namespace; alias expansion; names only what is listed; client-loaded catalog; selector reconciliation; management and schema validation). tests/server/management-provider-compat-carry.test.ts 23 pass / 3 fail.
  • With the change (rebased onto dev locally): the eight hosted-tool, carry, upgrade, Muse and combo files: 228 pass, 0 fail.
  • bun run typecheck, bun run structure:check, bun run privacy:scan: pass. Layout, layout tooling, file-size ratchet, Lab boundary, structure SSOT and quota-reset boundary guards: 128 pass, 0 fail.
  • bun run test:changed (2,405 files, isolated HOME; the run was split in two after a SIGTERM): 54,506 pass, 34 fail. All 34 are the environment-only set that fails identically on clean dev in this container: local-control-socket (17), the real-npm Codex CLI update suites (16), and one catalog-omit-disabled-native case.
  • NOT RUN: a live request to the reporting gateway; docs-site build; full bun run test; macOS/Windows.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Maintainer judgment

  • Value: a gateway with this restriction can keep both standalone hosted search and function calling instead of losing search entirely.
  • UX change scope: one new opt-in provider field. Separately, unsupportedHostedTools now survives a same-destination dashboard save, as the other upstream-behavior fields already do.
  • Regression evidence for existing users: with the new field unset, stripUnsupportedHostedTools gets the same set as before and skips the scan. The existing hosted-tool declaration, Muse tool-choice and combo send-contract suites pass unchanged.
  • Windows impact: none; request shaping and config only.
  • Verification scope / NOT RUN: see above.

…equests

A Gemini-backed OpenAI-compatible Responses gateway serves hosted web_search
alone and function calling alone, but answers HTTP 400 when one request
declares both. unsupportedHostedTools avoided the 400 only by removing the
search-only capability the gateway does serve.

unsupportedHostedToolsWithClientTools uses the same closed vocabulary and
alias expansion, and strips the named hosted declarations only when the
request also declares a function or custom tool, or a namespace with
members, in tools, additional_tools, or a tool_search_output result. It
feeds the same denial set as the unconditional list, so tool_choice and
allowed_tools reconciliation are shared. unsupportedHostedTools stays
authoritative, and an unset field leaves every body unchanged.

The field is validated by the config schema and management API, accepted
and cleared by PATCH, returned by GET, and classified in the editor and
model-rename rosters. Both hosted-tool lists now survive a same-destination
dashboard save; previously the form's POST overwrite dropped
unsupportedHostedTools. The hosted-tool denial section moves to its own
structure doc to keep chat-compat.md within the line budget.

Closes #8204
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 10, 2026 19:04
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T19:06:34.507978Z ddcbc48 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the enhancement New feature or request label Nov 10, 2026
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

…enies

Codex turns always carry client tools, so modelPreferHostedTools plus unsupportedHostedToolsWithClientTools on the same tool removed both the client image_gen declaration and the hosted tool. Reject the pair, as the unconditional list already does.

Refs #8204
@lidge-jun
lidge-jun merged commit 29dc089 into dev Nov 10, 2026
29 checks passed
@lidge-jun
lidge-jun deleted the codex/8204-conditional-hosted-tools branch November 10, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Provider compatibility] Conditional hosted-search filtering for Gemini Responses mixed with client tools

1 participant