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

* 🐛 fix(model-runtime): classify ollamacloud "context window exceeds limit" as ExceededContextWindow

ollamacloud surfaces context-window overflow as a generic 400 the upstream
labels ProviderBizError. Document the ollamacloud provenance on the existing
`context window exceeds` ECW pattern and add a regression test asserting the
message wins over the 400 / ProviderBizError catch-alls.

Fixes LOBE-9913

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* 🔥 chore(model-runtime): drop redundant ollamacloud note on ECW pattern

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Arvin Xu
2026-06-02 16:07:43 +08:00
committed by GitHub
parent cbc259094d
commit 0c3450de7c
@@ -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,