Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
📡 fix: Respect Custom Endpoint Stream Usage Opt-In (#13237)
Danny Avilacfe0f9f7f60a
diff --git a/packages/api/src/agents/__tests__/run-summarization.test.ts b/packages/api/src/agents/__tests__/run-summarization.test.tsindex 7d22511c21..ba31a0cdac 100644--- a/packages/api/src/agents/__tests__/run-summarization.test.ts+++ b/packages/api/src/agents/__tests__/run-summarization.test.ts@@ -205,6 +205,39 @@ beforeEach(() => {jest.clearAllMocks();});+// ---------------------------------------------------------------------------+// Suite: custom endpoint stream usage defaults+// ---------------------------------------------------------------------------+describe('custom endpoint stream usage defaults', () => {+ it('disables streamUsage by default for OpenAI-compatible custom endpoints', async () => {+ const agents = await callAndCapture({+ agents: [makeAgent({ endpoint: 'LiteLLM' })],+ });+ const clientOptions = agents[0].clientOptions as Record<string, unknown>;++ expect(clientOptions.streamUsage).toBe(false);+ expect(clientOptions.usage).toBe(true);+ });++ it('respects explicit streamUsage from endpoint-resolved model parameters', async () => {+ const agents = await callAndCapture({+ agents: [+ makeAgent({+ endpoint: 'LiteLLM',+ model_parameters: {+ model: 'gpt-4o',+ streamUsage: true,+ },+ }),+ ],+ });+ const clientOptions = agents[0].clientOptions as Record<string, unknown>;++ expect(clientOptions.streamUsage).toBe(true);+ expect(clientOptions.usage).toBe(true);+ });+});+// ---------------------------------------------------------------------------// Suite 1: reserveRatio// ---------------------------------------------------------------------------diff --git a/packages/api/src/agents/run.ts b/packages/api/src/agents/run.tsindex b0cc3105b6..e01f123e6a 100644--- a/packages/api/src/agents/run.ts+++ b/packages/api/src/agents/run.ts@@ -804,6 +804,10 @@ export async function createRun({);const modelParameters = normalizeAgentModelParameters(agent.model_parameters);+ const hasExplicitStreamUsage = Object.prototype.hasOwnProperty.call(+ modelParameters ?? {},+ 'streamUsage',+ );const llmConfig = Object.assign({provider,@@ -847,7 +851,9 @@ export async function createRun({customProviders.has(agent.provider) ||(agent.provider === Providers.OPENAI && agent.endpoint !== agent.provider)) {- llmConfig.streamUsage = false;+ if (!hasExplicitStreamUsage) {+ llmConfig.streamUsage = false;+ }llmConfig.usage = true;}