Skip to content

[Bug] PATCH /api/providers and the dashboard provider save silently drop preserveReasoningContentModels / requiresReasoningPlaceholderModels #5563

Closed

Description

@Veritas-7

Client or integration

Direct HTTP/API client (management API). The same loss is reachable from the OpenCodex dashboard.

Area

Dashboard

Summary

Two provider fields that this codebase otherwise treats as first-class cannot be written through the management API, and the dashboard save path silently discards them.

  • PATCH /api/providers?name=<provider> (the field-mask editor) does not recognize either field. A patch containing only these fields is rejected with no recognized fields to update; a patch that also contains any recognized field answers 200 {"success":true} while the two fields are dropped without an error.
  • POST /api/providers (the dashboard provider add/edit save) adopts the submitted body as the new row. The dashboard bundle never sends these two fields, so saving that provider from the UI erases them.

Both fields are declared as editor-writable in src/server/auth-cors.ts (lines 1028-1029), are registered as rename-migration fields in src/providers/model-rename-migration.ts (line 112), and are consumed by the openai-chat adapter (src/adapters/openai-chat/messages.ts:209,218,232,286,300-301) to replay reasoning_content on assistant tool-call messages.

Impact: an operator who needs reasoning replay for a custom provider (thinking-mode upstream) has to hand-edit config.json. A later unrelated save from the dashboard, or an ocx provider edit, removes the lists again, and the next resumed tool turn fails upstream with 400 The reasoning_content in the thinking mode must be passed back to the API. Nothing in that error points back to the provider save, so the breakage reads as intermittent.

I expected the field-mask editor to accept the fields it advertises as editor-writable, and a provider save to preserve fields the form does not carry, as it already does for apiKeyPool, modelCosts, modelContextWindows, modelAutoReviewModel, requestPacing and others.

Reproduction

Against a running instance (ocx start --port 10100), with a user-defined OpenAI-compatible provider that has the two lists set in config.json:

  1. GET /api/providers?name=<provider> shows preserveReasoningContentModels and requiresReasoningPlaceholderModels.
  2. PATCH /api/providers?name=<provider> with {"preserveReasoningContentModels":[...]} only, or with requiresReasoningPlaceholderModels only, returns 400 {"error":"no recognized fields to update"}.
  3. PATCH /api/providers?name=<provider> with {"preserveReasoningContentModels":12345,"liveModels":true} returns 200 {"success":true,...}. Re-reading the provider shows both lists exactly as before, and the invalid 12345 is never type-checked — the key was discarded before validation.
  4. In the dashboard, open that provider and press save without touching the two fields. The stored row loses both lists. The shipped bundle contains neither field name (gui/dist/assets/*.js, 0 matches), so the form cannot round-trip them.
  5. PUT /api/providers (the baseline/next batch editor) is not affected: mergeProviderEditorRow only applies keys whose value differs from the baseline, so the two lists survive that path.

Observed on the installed npm release, using the running instance's own management API and a custom provider row. No provider credentials, account identifiers, request bodies, or session data are included.

Version

2.59.0 (npm @bitkyc08/opencodex, also the latest published version at the time of this report)

Operating system

macOS 26.6.2 (build 25G83), arm64; Node v22.22.1; bun 1.4.2

Provider and model

Any user-defined provider row. Observed with a custom OpenAI-compatible provider fronting a thinking-mode model (DeepSeek V4 family) through the openai-chat adapter.

Logs or error output

$ TOKEN=$(cat <admin-api-token-file>)
$ curl -sS -X PATCH 'http://127.0.0.1:10100/api/providers?name=<provider>' \
    -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
    -d '{"liveModels":"not-a-boolean"}'
{"error":"liveModels must be a boolean"}
# HTTP 400 - control: route and auth are fine, a recognized field is validated

$ curl -sS -X PATCH 'http://127.0.0.1:10100/api/providers?name=<provider>' \
    -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
    -d '{"preserveReasoningContentModels":12345}'
{"error":"no recognized fields to update"}
# HTTP 400 - the field is not in the patch mask

$ curl -sS -X PATCH 'http://127.0.0.1:10100/api/providers?name=<provider>' \
    -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
    -d '{"preserveReasoningContentModels":12345,"liveModels":true}'
{"success":true,"name":"<provider>","disabled":false,"hasApiKey":true,...}
# HTTP 200 - accepted, and the requested field change is gone

$ curl -sS -X PATCH 'http://127.0.0.1:10100/api/providers?name=<provider>' \
    -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
    -d '{"requiresReasoningPlaceholderModels":12345}'
{"error":"no recognized fields to update"}
# HTTP 400 - same for the second field

$ shasum -a 256 config.json   # before and after the calls above
88c375c5...b8126  config.json
88c375c5...b8126  config.json
# unchanged: the first two calls are rejected before the save, and the 200 call
# persisted an unrelated in-memory model-discovery update without touching the row

The upstream failure this causes, after the lists are lost:

Provider error 400: The `reasoning_content` in the thinking mode must be passed back to the API.

Root cause

applyProviderPatchFields (src/server/management/provider-routes.ts:354) is the allow-list for the PATCH mask. It handles the neighbouring *Models fields — noStructuredOutputModels (line 673), unsupportedHostedTools (699), retainModels (719), omitReasoningEffortWithToolsModels (732) — but contains no branch for preserveReasoningContentModels or requiresReasoningPlaceholderModels. A grep for either name in that file returns no match.

Unsupported keys are not reported: the function ends with if (!touched) return { error: "no recognized fields to update" } (line 782) and the route only treats keys.some(key => key !== "disabled") (line 788) as an editor edit. So a patch that mixes the two fields with one recognized field passes every check and answers 200, while the two fields never reach the row.

POST /api/providers (line 1126) builds the new row from the submitted body and assigns it at line 1335. It already carries over fields the form does not send — apiKeyPool (1203), modelCosts (1208), autoReviewModel/autoReviewModelOverrides (1212-1213), upstreamWebsocket (1259), modelContextWindows (1262), modelAutoCompactTokenLimits (1271), plus the xai/Z.AI markers — using the submitted* = Object.hasOwn(...) pattern sampled before enrichment. Neither reasoning field is in that set.

The same trap is already acknowledged elsewhere in the codebase: src/oauth/index.ts:1268 puts preserveReasoningContentModels in OAUTH_RECONCILE_FIELDS but deliberately keeps requiresReasoningPlaceholderModels out (comment at 1270-1274), precisely because a reconcile that cannot see the user's value would wipe it.

Suggested fix

  1. Add mask branches for both fields in applyProviderPatchFields, following retainModels/noStructuredOutputModels: Object.hasOwn(rawBody, key), accept null/[] as an explicit clear, validate with nonBlankStringArrayConfigError, and delete the key when the resulting array is empty.
  2. Add carry-over in POST /api/providers for both fields, sampled with Object.hasOwn before enrichProviderFromCatalog like the other submitted* guards, so a dashboard save of an unrelated field cannot erase them. Explicit clearing can stay on PATCH.
  3. Either expose both fields in the provider form, or leave them API/config-only but make the save path round-trip them (option 2). The dashboard currently advertises them as editor fields in the policy table while the form cannot send them.

Redacted configuration

{
  "providers": {
    "<custom-provider>": {
      "type": "openai",
      "baseUrl": "https://<endpoint>/v1",
      "preserveReasoningContentModels": ["<thinking-model>"],
      "requiresReasoningPlaceholderModels": ["<thinking-model>"]
    }
  }
}

apiKey and account fields are omitted.

Additional context

Related but distinct: #5421 (routed subagent thinking turn loses reasoning text through a serialization gate), #4632 (custom-named providers do not inherit registry metadata), #1193 and #950 (replay-cache misses), #1802 (a sync path overwriting hand-edited config). None of them covers the management-API write paths dropping these two fields.

Local workaround in place here, for context only: a small guard that rewrites just these two lists for one provider row and requests a bound provider reload, because ocx config set is the only write path that keeps them. It does not use the management API and does not change adapter or upstream behaviour.

Checks

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

Activity

  1. added
    bug
    gui
    provider
    proxy
    tools
    on Sep 22, 2026
  2. lidge-jun commented on Sep 23, 2026

    @lidge-jun
    Owner

    Landed on dev in e635288 via #5642: provider saves (POST overwrite with the same name, PATCH and the dashboard save) now keep preserveReasoningContentModels and requiresReasoningPlaceholderModels, together with foldDeveloperRoleToSystem, reasoningWireFormat and omitReasoningEffortWithToolsModels, while settings bound to a changed destination are not carried over. Merges into dev do not auto-close issues, so closing manually; it ships with the next release cut from dev. Please reopen if it still reproduces there.

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

    bugguiproviderproxytools

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions