From 6165d39c61ade7dd60aa8a6ce067a1da3d5b0cc4 Mon Sep 17 00:00:00 2001 From: eliya-mazoz <104295739+eliya-mazoz@users.noreply.github.com> Date: Tue, 3 Mar 2026 09:06:02 +0200 Subject: [PATCH] fix: use custom OpenAI-compatible provider to resolve empty responses Fixes #5210, #5674, #10573, #15756 ## Problem Custom OpenAI-compatible providers configured via @ai-sdk/openai-compatible return empty responses ({ data: {}, request: {}, response: {} }) despite the provider API working correctly when called directly. ## Root Cause The official @ai-sdk/openai-compatible package does not properly emit text-start and text-delta events during streaming, causing the SDK's session.prompt() to receive no content even though the API returns valid responses. ## Solution Replace the official createOpenAICompatible with the custom createGitHubCopilotOpenAICompatible implementation which properly handles: - text-start event emission before streaming begins - text-delta events with actual content - reasoning-delta events for o1 models - Proper state management for isActiveText/isActiveReasoning ## Technical Details The custom implementation in openai-compatible-chat-language-model.ts (lines 477-503) correctly handles delta.content by: 1. Emitting text-start event when streaming begins 2. Emitting text-delta events with delta content 3. Managing state transitions between reasoning and text This fix applies the same working implementation used for @ai-sdk/github-copilot to all @ai-sdk/openai-compatible providers. ## Testing Tested with custom OpenAI-compatible endpoint (llmlite-dev) running gpt-4o: - Before: Empty responses - After: Full responses with proper streaming Co-authored-by: OpenCode AI --- packages/opencode/src/provider/provider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts index 817038365246..04b07443cb53 100644 --- a/packages/opencode/src/provider/provider.ts +++ b/packages/opencode/src/provider/provider.ts @@ -92,7 +92,7 @@ export namespace Provider { "@ai-sdk/google-vertex": createVertex, "@ai-sdk/google-vertex/anthropic": createVertexAnthropic, "@ai-sdk/openai": createOpenAI, - "@ai-sdk/openai-compatible": createOpenAICompatible, + "@ai-sdk/openai-compatible": createGitHubCopilotOpenAICompatible, "@openrouter/ai-sdk-provider": createOpenRouter, "@ai-sdk/xai": createXai, "@ai-sdk/mistral": createMistral,