Skip to content

馃摗 fix: Respect Custom Endpoint Stream Usage Opt-In - #13237

Merged
danny-avila merged 1 commit into
devfrom
danny-avila/respect-custom-stream-usage
May 21, 2026
Merged

danny-avila merged 1 commit into
devfrom
danny-avila/respect-custom-stream-usage

Conversation

@danny-avila

Copy link
Copy Markdown
Collaborator

Summary

I fixed custom/OpenAI-compatible agent runs so an explicit endpoint streamUsage opt-in survives the compatibility default.

  • Preserve streamUsage when endpoint-resolved model parameters explicitly define it.
  • Keep the default compatibility behavior for custom/OpenAI-compatible endpoints by disabling streamed usage when no explicit opt-in is present.
  • Add focused createRun tests for the default behavior and the explicit opt-in path.

Change Type

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

Testing

  • Ran NODE_PATH=/Users/danny/Projects/LibreChat/node_modules /Users/danny/Projects/LibreChat/node_modules/.bin/jest src/agents/__tests__/run-summarization.test.ts --runInBand --coverage=false from packages/api.

Test Configuration:

  • Node.js v20.19.5
  • Jest focused package test in packages/api

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 May 21, 2026 19:12

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 agent run configuration for OpenAI-compatible custom endpoints so that streamUsage is only forced off when there is no explicit endpoint/model opt-in, preserving explicit streamUsage values while keeping the existing compatibility default.

Changes:

  • Detect explicit streamUsage presence in resolved model parameters and avoid overriding it for OpenAI-compatible custom endpoints.
  • Preserve existing compatibility behavior by defaulting streamUsage to false for custom/OpenAI-compatible endpoints when not explicitly set.
  • Add targeted unit tests covering the default-disable path and the explicit opt-in path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/api/src/agents/run.ts Only disables streamUsage for custom/OpenAI-compatible endpoints when it wasn鈥檛 explicitly provided via model parameters.
packages/api/src/agents/__tests__/run-summarization.test.ts Adds tests ensuring default streamUsage=false for OpenAI-compatible custom endpoints and honoring explicit streamUsage=true.

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

@danny-avila
danny-avila changed the base branch from main to dev May 21, 2026 19:18
@danny-avila
danny-avila marked this pull request as ready for review May 21, 2026 19:18
@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 馃殌 deployed

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

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

鈩癸笍 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 merged commit cfe0f9f into dev May 21, 2026
11 checks passed
@danny-avila
danny-avila deleted the danny-avila/respect-custom-stream-usage branch May 21, 2026 19:40
fuuuzzy pushed a commit to fuuuzzy/LibreChat that referenced this pull request May 22, 2026
danieldjupvik added a commit to danieldjupvik/LibreChat-fork that referenced this pull request May 22, 2026
Revert in-place fork edit to packages/api/src/agents/run.ts and use
upstream's new model_parameters.streamUsage opt-in (PR LibreChat-AI#13237) instead.
A fork-only helper sets streamUsage=true on LiteLLM-endpoint agents
(walking subagentAgentConfigs recursively) before createRun runs, so
upstream code stays vanilla and cost-breakdown behavior on LiteLLM
is preserved.
ThomasVuNguyen pushed a commit to ThomasVuNguyen/LibreChat that referenced this pull request Jul 15, 2026
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