Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✅ test(model-runtime): classify ollamacloud "context window exceeds limit" as ExceededContextWindow (#15411)

Arvin Xu0c3450de7ced
diff --git a/packages/model-runtime/src/errors/match.test.ts b/packages/model-runtime/src/errors/match.test.ts
index 0896e0197f4..074b9862262 100644
--- a/packages/model-runtime/src/errors/match.test.ts
+++ b/packages/model-runtime/src/errors/match.test.ts
@@ -17,6 +17,19 @@ describe('matchErrorPattern', () => {
);
});
+ it('classifies ollamacloud "context window exceeds limit" as ExceededContextWindow, not ProviderBizError (LOBE-9913)', () => {
+ // ollamacloud surfaces context-window overflow as a generic 400 that the
+ // upstream labels ProviderBizError. The ECW message pattern sits before the
+ // 400 / ProviderBizError catch-alls, so the message wins regardless.
+ expect(
+ matchErrorPattern({
+ errorType: AgentRuntimeErrorType.ProviderBizError,
+ message: '400 "invalid params, context window exceeds limit (ref: 0x123)"',
+ provider: 'ollamacloud',
+ })?.code,
+ ).toBe(AgentRuntimeErrorType.ExceededContextWindow);
+ });
+
it('disambiguates 429-class rate limit from balance-class quota', () => {
expect(matchErrorPattern({ message: 'rate_limit_exceeded' })?.code).toBe(
AgentRuntimeErrorType.RateLimitExceeded,