responses: no policy surface for the client tool protocol — handling is inferred from provider templates instead of the routed call

Author: hrygoCreated Sep 29, 2026Updated Sep 29, 2026

Is it a request payload issue? [ ] Yes, this is a request payload issue. I am using a client/cURL to send a request payload, but I received an unexpected error. [x] No, it's another issue.

If it's a request payload issue, you MUST know N/A — the request is well-formed. The problem is that the proxy has nowhere to express "how should the tool protocol be handled on this route", so it guesses from templates and provider type.

Describe the bug

Summary

There is no configuration surface and no runtime resolver for the Responses client tool protocol. Any future handling would have to be decided either globally or by hardcoding a provider list. Both are wrong: the correct answer depends on the actual routed call — the selected provider, the auth kind, the real upstream model, the actual target protocol, and the endpoint — none of which are visible when a model alias is resolved to a template. Worse, a per-model flag in models.json would create a second source of truth that can disagree with runtime routing.

Observed behavior

  • Whether a route can complete a client tool_search round trip is decided by template metadata and provider name, not by the route that will actually be used. A public alias is therefore advertised as searchable even when the credential/model that would serve it cannot close the loop — the client then sends the protocol and the request fails at the far end.
  • The converse also happens: a route that could bridge is left on native passthrough and silently drops discovery, because speaking the Responses wire format is treated as sufficient. xai is the case we observed — its executor strips the tool_search built-in, so a native passthrough loses the discovery entry point without any error. That came from the PR author's own testing; no request sample is attached here.
  • There is no way for an operator to disable a lossy adaptation for one route, or to opt a route into one, without a code change.

Root cause chain

  1. internal/client/codex/models/models.go builds the client model catalog from codex_client_models.json templates plus applyCodexClientProviderCapabilities, which derives capability flags from ProvidersForModel — a provider name set, not a route.
  2. internal/config has no requests.responses-tools section, so nothing downstream can receive a policy at all.
  3. Nothing in sdk/cliproxy/auth captures the resolved route (provider + auth kind + upstream model + executor format + base URL) into a comparable value, so even a policy engine would have nothing to match against.

CLI Type All providers.

Model Name All models. The defect is most visible on public aliases that fan out to several credentials or model pools with different capabilities.

LLM Client Codex-style clients that read supports_search_tool from /v1/models and switch between the deferred-tool and the eager-tool request shape.

Request Information

N/A — this is a configuration and routing concern, not a payload defect. The observable symptom is in the model catalog served to the client:

bash
curl -s http://127.0.0.1:8317/v1/models | jq '.data[] | select(.id=="gpt-5.6") | {id, supports_search_tool}'
# advertised true, while the credential that actually serves gpt-5.6 strips
# tool_search upstream -> the client's first tool_search call can never be answered

Expected behavior

  • Exactly one configuration source, requests.responses-tools, with no second policy in models.json, model aliases, or plugin YAML. An absent block is a supported configuration and applies the convention defaults.

  • Route rules match the call the runtime actually makes, never the name the client typed. Required exact conditions: provider, auth-kind, upstream-model, upstream-format; plus base-url for API-key routes so the same provider/model on two endpoints cannot share a rule. OAuth routes leave base-url empty. No wildcards, no regex, no inference from model names.

  • upstream-format is the target format the selected executor declares, not a value derived from the provider name. The mapping below is what the executors declare today, recorded here so a rule author knows what to write — it is documentation, not a code-enforced lookup, and it changes whenever an executor changes its target format:

    provider upstream-format
    codex, xai, meta codex
    claude claude
    gemini, vertex, aistudio gemini
    kimi openai
    antigravity antigravity
    openai-compatible-<name> openai
  • Convention over configuration: the effective policy is derived from the upstream format and the provider when no rule matches. client-search: native only where the provider forwards the tool_search built-in unchanged; bridge everywhere else. meta is the one provider that needs a portable tool surface today, because its upstream rejects type: custom and requires every property to be listed in required.

  • Lossy strategies are never inferred; they stay opt-in. The single exception is the portable-surface folding for meta, whose upstream accepts nothing else.

  • A match condition naming a provider, auth kind, model, or format the call does not have never errors — the rule simply does not match, and the convention applies. A misspelled strategy enum does error, at config load: unknown client-search / custom-tools / custom-grammar / local-refs / search-required values, missing required match conditions, an api-key rule without base-url, and a base-url carrying userinfo, a query, or a fragment are all rejected before the config is accepted.

  • Overlapping rules with conflicting strategies are rejected at load time; a dynamic conflict at routing time returns an explicit configuration error, never a silent first match.

  • Hot config updates replace the compiled policy and refresh limits without resetting already-counted usage or evicting in-flight attempts. An invalid reconfiguration keeps the previous policy: a partial route table is never published before budget validation completes.

  • A single emergency gate enabled: false turns the whole feature off without deleting anything else.

Screenshots N/A.

OS Type

  • OS: macOS
  • Version: 26.x / arm64 (not platform specific)

Additional context

Scope in this issue

  • internal/config: the requests.responses-tools block (enabled gate, limits, routes[] with the match conditions and the client-search / custom-tools / custom-grammar / schema strategy enums), load-time validation, and v8 migration handling.
  • Compile-time validation: unknown enum values, illegal strategy combinations, non-positive or unreasonable limits (negative never means unlimited), and statically conflicting rule overlaps are rejected.
  • NormalizeBaseURL for endpoint comparison (lowercase scheme and host, default ports dropped, no trailing slash, path case preserved).
  • Runtime resolution: build the route identity from the selected credential and executor format, read only non-sensitive endpoint metadata, and never let keys or tokens enter the policy path.
  • Strategy enums: client-search = inherit | native | bridge | disabled; custom-tools = inherit | native | function | strip | reject; custom-grammar = reject | describe; schema.complete-search-required = tri-state; schema.local-refs = preserve | inline.
  • Tri-state semantics: an absent schema strategy follows the route convention, and schema.local-refs and schema.complete-search-required resolve independently — stating one does not opt the route out of the other.

Out of scope

The bridges themselves, the capability aggregation that turns this into supports_search_tool, and any change to existing executors. This issue lands the policy surface and its resolver only.

Related issues

Depends on the contract/identity representation. Feeds the search bridge, the custom bridge, the portable-surface folding, and the capability-declaration issue in this series.

Source: router-for-me/CLIProxyAPI