Skip to content

Commit e0bb1c4

Browse files
author
Jorge Vidaurre
committed
fix(providers): detect opencode's Vercel AI SDK fatal errors (#978)
OpenCode is built on the Vercel AI SDK; real-world failures surface as AI_APICallError / AI_LoadAPIKeyError etc. (anomalyco/opencode#2245, #1061, #1631, #2944) rather than a non-zero exit, so add them to PROVIDER_FATAL alongside the existing litellm/aider signature.
1 parent badee88 commit e0bb1c4

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

‎src/lib/llm-clis.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ const PROVIDER_FATAL = [
136136
/insufficient balance|please recharge|insufficient_quota|exceeded your current quota/i,
137137
/The supported API model names are/,
138138
/invalid api key|incorrect api key/i,
139+
/AI_\w*Error/, // opencode (Vercel AI SDK) — AI_APICallError, AI_LoadAPIKeyError, etc. (#978)
139140
];
140141

141142
/** Returns the matched failure line for logging, or null when output looks healthy. */

‎test/llm-usage.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ describe('detectProviderFatalError (#936 — exit-0 API failures must fail loud)
143143
expect(detectProviderFatalError('[1113][Insufficient balance or no resource package. Please recharge.]')).toBeTruthy();
144144
expect(detectProviderFatalError('You exceeded your current quota, please check your plan')).toBeTruthy();
145145
expect(detectProviderFatalError('Error: invalid api key provided')).toBeTruthy();
146+
expect(detectProviderFatalError('AI_APICallError: Incorrect API key provided')).toBeTruthy();
147+
expect(detectProviderFatalError('AI_APICallError: No auth credentials found')).toBeTruthy();
146148
});
147149
it('stays quiet on healthy output', async () => {
148150
const { detectProviderFatalError } = await import('../src/lib/llm-clis.js');

0 commit comments

Comments
 (0)