Skip to content

[Bug] Custom-named providers on known endpoints do not inherit reasoning replay/tool-choice compatibility metadata #4632

Closed as not planned

Description

@RHODIZSECURITY

Client or integration

Claude Code / OpenAI-compatible routing through a provider row whose configured name differs from the built-in registry id, while its fixed upstream endpoint is a known OpenCodex provider destination.

Provider or upstream service

Concrete reproduction: official DeepSeek API at https://api.deepseek.com, configured under the name DeepSeek instead of registry id deepseek; model deepseek-flash.

OpenCodex version

2.54.0 on Linux, reproduced 2026-09-13/14.

Current behaviour

OpenCodex already has destination-based enrichment for custom provider names. When the name lookup misses but the fixed endpoint matches a known registry entry, enrichProviderFromRegistry() calls enrichReasoningMetadataByDestination().

That fallback currently restores only part of the reasoning contract (summary/effort metadata). It can omit transport-critical compatibility metadata such as:

  • preserveReasoningContentModels;
  • requiresReasoningPlaceholderModels;
  • autoToolChoiceOnlyModels.

For DeepSeek thinking mode, those are not cosmetic picker hints. Missing replay metadata can cause a later tool-call continuation to be sent without reasoning_content, which upstream rejects with:

The `reasoning_content` in the thinking mode must be passed back to the API.

Missing the tool-choice metadata separately leaves forced/required selectors eligible for the same custom-named provider even though DeepSeek thinking mode only accepts automatic selection.

Why this is distinct from existing replay issues

This is not the bounded replay-cache miss from #1193 and not the ordinary replay path from #950. Those issues assume the effective provider is already correctly opted into reasoning replay.

Here the failure happens earlier: a custom/case-changed provider name on a known fixed endpoint can fail to inherit the registry contract at all.

Minimal reproduction

{
  "providers": {
    "DeepSeek": {
      "adapter": "openai-chat",
      "baseUrl": "https://api.deepseek.com",
      "models": ["deepseek-flash"]
    }
  }
}

Then load/enrich the row through production config logic and compare it with the built-in deepseek row. Before the local fix, the destination fallback does not necessarily restore the full replay/tool-choice metadata even though the endpoint is the same trusted fixed destination.

A real multi-turn Claude Code session on this shape produced repeated final 400s after earlier combo targets were unavailable:

Provider error 400: {"error":{"message":"The `reasoning_content` in the thinking mode must be passed back to the API.","type":"invalid_request_error","param":null,"code":"invalid_request_error"}}

Root cause

enrichReasoningMetadataByDestination() is intentionally narrow, but it is narrower than the wire contract it is trying to reconstruct. The built-in DeepSeek entry declares replay/tool-choice behaviour, while the custom-name fallback only restores effort/summary metadata.

The router already resolves the endpoint through registryEntryForProviderDestination(), which is restricted to known fixed key destinations. That gives a safe authority boundary for copying these model-scoped compatibility lists as fill-only defaults.

Suggested fix

When a custom provider matches a known fixed registry destination, fill these lists when the user did not explicitly provide them:

if (!prov.preserveReasoningContentModels && destination?.preserveReasoningContentModels) {
  prov.preserveReasoningContentModels = [...destination.preserveReasoningContentModels];
}
if (!prov.requiresReasoningPlaceholderModels && destination?.requiresReasoningPlaceholderModels) {
  prov.requiresReasoningPlaceholderModels = [...destination.requiresReasoningPlaceholderModels];
}
if (!prov.autoToolChoiceOnlyModels && destination?.autoToolChoiceOnlyModels) {
  prov.autoToolChoiceOnlyModels = [...destination.autoToolChoiceOnlyModels];
}

Important: an explicit [] remains an operator opt-out and must not be overwritten.

Local verification

A bounded local patch adds regression coverage showing:

  • custom DeepSeek on the official endpoint inherits the replay list;
  • an explicit empty replay list remains empty;
  • the effective deployed provider exposes both replay and auto-tool-choice model lists;
  • production serialization of a tool-call continuation includes the original reasoning_content.

Focused test suites pass with no regressions.

Checks

Activity

  1. added
    provider
    tools
    on Sep 14, 2026
  2. github-actions commented on Sep 14, 2026

    @github-actions
    Contributor

    Issue closed: use an issue template

    Thanks for taking the time to submit this issue. It was closed automatically because it was not opened with a recognized issue template (Bug report, Feature request, Documentation, or Provider compatibility). Freeform and API-opened issues cannot skip this check.

    • This issue does not use a recognized issue template.

    Please edit the issue to add:

    • Open a new issue with the Bug report, Feature request, Documentation, or Provider compatibility template.
    • Or edit this issue so the body uses the template section headings for the kind of report you are filing.

    See the Contributing guide for details.

    Once the report passes the automated checks, it will be reopened automatically unless a maintainer has changed its state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    providertools

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions