Skip to content

馃獧 fix: Max Output Tokens Refactor for Responses API - #8972

Merged
danny-avila merged 1 commit into
devfrom
fix/max-completion-token-error
Aug 10, 2025
Merged

danny-avila merged 1 commit into
devfrom
fix/max-completion-token-error

Conversation

@dustinhealy

Copy link
Copy Markdown
Collaborator

Summary

This pull request fixes an error raised in #8966 stemming from how the maxTokens parameter is mapped for the new models, ensuring that when the useResponsesApi flag is enabled, maxTokens is moved to max_output_tokens instead of max_completion_tokens.

  • Updated OpenAIClient.js, memory.ts, and llm.ts to set max_output_tokens (instead of max_completion_tokens) when useResponsesApi is true, and to use max_completion_tokens otherwise. This ensures consistent parameter mapping for GPT-5+ models. [1] [2] [3]

Testing and validation:

  • Added and modified tests in client.test.js to verify that maxTokens is correctly moved to either max_output_tokens or max_completion_tokens depending on the model and useResponsesApi flag. Tests also confirm that only GPT-5+ models are affected by this logic. [1] [2]
  • Added tests in memory.test.ts to ensure the correct parameter (max_output_tokens or max_completion_tokens) is set in the LLM config passed to the agent runner, based on the value of useResponsesApi.
  • Updated llm.spec.ts to expect max_output_tokens instead of max_completion_tokens when useResponsesApi is true.

Change Type

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

Testing

Verified absence of error when receiving responses in conversations with gpt-5 as a model and max token params set.
Confirmed no regression with earlier models and non Responses API requests using gpt-4o.

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


if (this.isOmni === true && modelOptions.max_tokens != null) {
modelOptions.max_completion_tokens = modelOptions.max_tokens;
const paramName =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

there's no need to update this file as it's no longer used and will be removed soon.

@danny-avila danny-avila changed the title 馃敤 fix: Max Output Tokens Refactor for Responses API 馃獧 fix: Max Output Tokens Refactor for Responses API Aug 10, 2025
@danny-avila
danny-avila merged this pull request into dev Aug 10, 2025
@danny-avila
danny-avila deleted the fix/max-completion-token-error branch August 10, 2025 17:58
danny-avila pushed a commit that referenced this pull request Aug 10, 2025
馃獧 fix: Max Output Tokens Refactor for Responses API (#8972)

chore: Remove `max_output_tokens` from model kwargs in `titleConvo` if provided
pedrojreis pushed a commit to nosportugal/LibreChat that referenced this pull request Sep 4, 2025
馃獧 fix: Max Output Tokens Refactor for Responses API (LibreChat-AI#8972)

chore: Remove `max_output_tokens` from model kwargs in `titleConvo` if provided
Guiraud pushed a commit to Guiraud/LibreChat that referenced this pull request Nov 21, 2025
馃獧 fix: Max Output Tokens Refactor for Responses API (LibreChat-AI#8972)

chore: Remove `max_output_tokens` from model kwargs in `titleConvo` if provided
patricksn3ll pushed a commit to patricksn3ll/LibreChat that referenced this pull request Dec 11, 2025
馃獧 fix: Max Output Tokens Refactor for Responses API (LibreChat-AI#8972)

chore: Remove `max_output_tokens` from model kwargs in `titleConvo` if provided
jcbartle pushed a commit to jcbartle/LibreChat that referenced this pull request May 11, 2026
馃獧 fix: Max Output Tokens Refactor for Responses API (LibreChat-AI#8972)

chore: Remove `max_output_tokens` from model kwargs in `titleConvo` if provided
ThomasVuNguyen pushed a commit to ThomasVuNguyen/LibreChat that referenced this pull request Jul 15, 2026
馃獧 fix: Max Output Tokens Refactor for Responses API (LibreChat-AI#8972)

chore: Remove `max_output_tokens` from model kwargs in `titleConvo` if provided
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.

2 participants