Skip to content

Commit 6165d39

Browse files
eliya-mazozOpenCode AI
andcommitted
fix: use custom OpenAI-compatible provider to resolve empty responses
Fixes anomalyco#5210, anomalyco#5674, anomalyco#10573, anomalyco#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 <[email protected]>
1 parent 6deb27e commit 6165d39

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎packages/opencode/src/provider/provider.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export namespace Provider {
9292
"@ai-sdk/google-vertex": createVertex,
9393
"@ai-sdk/google-vertex/anthropic": createVertexAnthropic,
9494
"@ai-sdk/openai": createOpenAI,
95-
"@ai-sdk/openai-compatible": createOpenAICompatible,
95+
"@ai-sdk/openai-compatible": createGitHubCopilotOpenAICompatible,
9696
"@openrouter/ai-sdk-provider": createOpenRouter,
9797
"@ai-sdk/xai": createXai,
9898
"@ai-sdk/mistral": createMistral,

0 commit comments

Comments
 (0)