Skip to content

💭 fix: Preserve Custom Endpoint Reasoning Params#13447

Merged
danny-avila merged 5 commits into
devfrom
danny-avila/fix-custom-reasoning-passthrough
Jun 1, 2026
Merged

💭 fix: Preserve Custom Endpoint Reasoning Params#13447
danny-avila merged 5 commits into
devfrom
danny-avila/fix-custom-reasoning-passthrough

Conversation

@danny-avila

Copy link
Copy Markdown
Owner

Summary

I fixed custom OpenAI-compatible endpoint reasoning so LibreChat no longer loses the selected reasoning effort before the request reaches provider gateways.

  • Added a configurable customParams.reasoningFormat for custom endpoints with reasoning_effort, reasoning_object, and disabled modes.
  • Routed custom Chat Completions reasoning through modelKwargs so LangChain forwards it for provider-prefixed and proxy-defined model IDs.
  • Defaulted Vercel AI Gateway endpoints to reasoning: { effort }, while keeping plain custom endpoints on the OpenAI-compatible reasoning_effort format.
  • Preserved existing OpenAI/Azure Responses API and OpenRouter handling.
  • Added coverage for default custom endpoints, Vercel defaults and overrides, disabled passthrough, Cloudflare-style custom endpoints, and config schema validation.

Fixes #13442.

Change Type

  • Bug fix (non-breaking change which fixes an issue)

Testing

  • Ran npx jest src/endpoints/openai/llm.spec.ts src/endpoints/openai/config.spec.ts src/endpoints/openai/config.backward-compat.spec.ts --runInBand from packages/api.
  • Ran npx jest specs/config-schemas.spec.ts --runInBand from packages/data-provider.
  • Ran npm run build from packages/data-provider.
  • Ran npm run build from packages/api.
  • Ran git diff --check.
  • Verified the actual ChatOpenAI request body with a fake fetch: Vercel sends reasoning: { effort: "low" }, plain custom sends reasoning_effort: "low", and disabled sends no reasoning param.
  • Verified a live Vercel AI Gateway request with openai/gpt-5-mini, streaming off, and reasoning_effort: low; the response returned output_token_details.reasoning: 64.

Test Configuration:

  • Node.js: v20.19.5
  • Endpoint tested live: Vercel AI Gateway
  • Live model tested: openai/gpt-5-mini
  • Streaming: false

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes

Copilot AI review requested due to automatic review settings June 1, 2026 13:01

Copy link
Copy Markdown
Owner Author

@codex review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes reasoning parameter passthrough for OpenAI-compatible custom endpoints, ensuring the selected reasoning effort/shape is preserved through LangChain/OpenAI client configuration (not dropped due to model-name gating), while adding an endpoint-level configuration knob to choose the reasoning parameter format (including a Vercel AI Gateway default).

Changes:

  • Added ReasoningParameterFormat plus config/schema/type support for customParams.reasoningFormat.
  • Updated OpenAI LLM config building to route custom-endpoint reasoning via modelKwargs (and support reasoning_object / disabled), defaulting Vercel gateways to the reasoning object shape.
  • Expanded unit tests across API + data-provider to validate default behavior, overrides, disabled passthrough, and schema validation.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/data-provider/src/types.ts Extends TConfig.customParams to include reasoningFormat.
packages/data-provider/src/schemas.ts Introduces ReasoningParameterFormat enum + Zod enum schema.
packages/data-provider/src/config.ts Validates customParams.reasoningFormat in endpointSchema.
packages/data-provider/specs/config-schemas.spec.ts Adds schema acceptance/rejection tests for reasoningFormat.
packages/api/src/endpoints/openai/llm.ts Implements applyReasoningConfig() and routes custom reasoning via modelKwargs with configurable format.
packages/api/src/endpoints/openai/llm.spec.ts Adds coverage for custom reasoning passthrough/object/disabled modes.
packages/api/src/endpoints/openai/config.ts Adds Vercel default + explicit override plumbing for reasoningFormat.
packages/api/src/endpoints/openai/config.spec.ts Updates/extends reasoning tests (custom endpoints, Vercel defaults/overrides).
packages/api/src/endpoints/openai/config.backward-compat.spec.ts Updates backward-compat expectations for Cloudflare/custom reasoning passthrough.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/api/src/endpoints/openai/llm.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 75f3bd9bf6

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/data-provider/src/config.ts
Comment thread packages/api/src/endpoints/openai/llm.ts Outdated
Comment thread packages/api/src/endpoints/openai/llm.ts
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13447 index is now live on the MCP server.
Deploy run

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6007a01ee3

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/api/src/endpoints/openai/llm.ts Outdated
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13447 index is now live on the MCP server.
Deploy run

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 517ae0ba82

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/api/src/endpoints/openai/llm.ts
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13447 index is now live on the MCP server.
Deploy run

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila

Copy link
Copy Markdown
Owner Author

@codex review

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13447 index is now live on the MCP server.
Deploy run

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila danny-avila marked this pull request as ready for review June 1, 2026 14:02
@danny-avila danny-avila changed the base branch from main to dev June 1, 2026 14:04
@danny-avila danny-avila force-pushed the danny-avila/fix-custom-reasoning-passthrough branch from ca0d552 to e3fbd6e Compare June 1, 2026 14:07
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13447 index is now live on the MCP server.
Deploy run

@danny-avila danny-avila force-pushed the danny-avila/fix-custom-reasoning-passthrough branch from e3fbd6e to ebaf01b Compare June 1, 2026 20:21
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13447 index is now live on the MCP server.
Deploy run

@danny-avila

Copy link
Copy Markdown
Owner Author

@codex review

@danny-avila danny-avila force-pushed the danny-avila/fix-custom-reasoning-passthrough branch from c1d5cf6 to 8ead5c4 Compare June 1, 2026 21:00
@danny-avila

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13447 index is now live on the MCP server.
Deploy run

@danny-avila danny-avila force-pushed the danny-avila/fix-custom-reasoning-passthrough branch from 8ead5c4 to 4f1f27e Compare June 1, 2026 22:00
@danny-avila

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13447 index is now live on the MCP server.
Deploy run

@danny-avila danny-avila changed the title 🧭 fix: Preserve Custom Endpoint Reasoning Params 💭 fix: Preserve Custom Endpoint Reasoning Params Jun 1, 2026
@danny-avila danny-avila merged commit 2ab432b into dev Jun 1, 2026
17 checks passed
@danny-avila danny-avila deleted the danny-avila/fix-custom-reasoning-passthrough branch June 1, 2026 22:20
fuuuzzy pushed a commit to fuuuzzy/LibreChat that referenced this pull request Jun 4, 2026
* fix: Preserve custom endpoint reasoning params

* fix: Address custom reasoning review cases

* fix: Format configured reasoning defaults

* fix: Honor dropped reasoning params

* fix: Configure custom reasoning response key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reasoning params are unreliable for some OpenAI-compatible custom endpoints due to model-name gating and provider-specific payload shapes

2 participants