๐คฏ 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
๐ fix(model-runtime): converge 2nd residue wave + unmap payload-too-large from ECW (#16053)
Arvin Xuce2e517be98d
diff --git a/packages/model-runtime/src/errors/match.test.ts b/packages/model-runtime/src/errors/match.test.tsindex df83a007c87..d43dc92e833 100644--- a/packages/model-runtime/src/errors/match.test.ts+++ b/packages/model-runtime/src/errors/match.test.ts@@ -280,10 +280,6 @@ describe('matchErrorPattern โ refines the UpstreamHttpError fallback bucket',],['ๆๅกๅจ้ฎ้ข่ฐ่ฏไธญ', AgentRuntimeErrorType.ProviderServiceUnavailable],['1m ไธไธๆๅทฒ็ปๅ จ้ๅฏ็จ๏ผ่ฏทๅฏ็จ 1m ไธไธๆๅ้่ฏ', AgentRuntimeErrorType.ExceededContextWindow],- [- 'Request body too large for gpt-4o model. Max size: 1000000 tokens.',- AgentRuntimeErrorType.ExceededContextWindow,- ],["Model 'glm-5.2:cloud' is not allowed on this server.", AgentRuntimeErrorType.ModelNotFound],['User has been banned (request id: 2026...)', AgentRuntimeErrorType.PermissionDenied],['Only Codex clients can use this group', AgentRuntimeErrorType.PermissionDenied],@@ -301,3 +297,70 @@ describe('matchErrorPattern โ refines the UpstreamHttpError fallback bucket',).toBe(expected);});});++describe('matchErrorPattern โ second residue convergence round', () => {+ const cases: [string, string][] = [+ ['The provided model identifier is invalid.', AgentRuntimeErrorType.ModelNotFound],+ [+ 'Incorrect model ID. Please request to view the model page',+ AgentRuntimeErrorType.ModelNotFound,+ ],+ ['<html><head><title>403 Forbidden</title></head>', AgentRuntimeErrorType.PermissionDenied],+ [+ 'Access denied due to Virtual Network/Firewall rules.',+ AgentRuntimeErrorType.PermissionDenied,+ ],+ [+ 'This channel does not allow the current client (detected: r9)',+ AgentRuntimeErrorType.PermissionDenied,+ ],+ [+ "However, the model's context length is 200000 tokens.",+ AgentRuntimeErrorType.ExceededContextWindow,+ ],+ [+ 'Image inference is not supported on this endpoint. Please use /images/generations',+ AgentRuntimeErrorType.CapabilityNotSupported,+ ],+ ['ๅฝๅๆจกๅไธๆฏๆSSE่ฐ็จๆนๅผใ', AgentRuntimeErrorType.CapabilityNotSupported],+ [+ 'This model is unavailable for free. The paid version is available now',+ AgentRuntimeErrorType.InsufficientQuota,+ ],+ ['fetch failed', AgentRuntimeErrorType.ProviderNetworkError],+ ['404 page not found', AgentRuntimeErrorType.UserConfigError],+ [+ '{"errors":[{"code":7003,"message":"No route for that URI"}]}',+ AgentRuntimeErrorType.UserConfigError,+ ],+ [+ 'invalid params, invalid reasoning.type: "enabled" (allowed: adaptive, disabled)',+ AgentRuntimeErrorType.InvalidRequestFormat,+ ],+ [+ 'Error from provider (Moonshot AI): invalid thinking: only type=enabled is allowed',+ AgentRuntimeErrorType.InvalidRequestFormat,+ ],+ [+ 'function_declarations[0].parameters.properties[set]',+ AgentRuntimeErrorType.InvalidRequestFormat,+ ],+ ['<!doctype html><meta charset="utf-8">', AgentRuntimeErrorType.UpstreamGatewayError],+ ];++ it.each(cases)('classifies %j', (message, expected) => {+ expect(+ matchErrorPattern({ errorType: AgentRuntimeErrorType.ProviderBizError, message })?.code,+ ).toBe(expected);+ });++ it('does NOT classify a payload-size (413) rejection as ExceededContextWindow', () => {+ // A request-body / 413 size limit is not the same as the model context+ // window โ it must stay out of ExceededContextWindow.+ const code = matchErrorPattern({+ errorType: AgentRuntimeErrorType.ProviderBizError,+ message: 'Request body too large for gpt-4o model. Max size: 1000000 tokens.',+ })?.code;+ expect(code).not.toBe(AgentRuntimeErrorType.ExceededContextWindow);+ });+});diff --git a/packages/model-runtime/src/errors/patterns.ts b/packages/model-runtime/src/errors/patterns.tsindex 23ad58e7315..e5bc5b99a79 100644--- a/packages/model-runtime/src/errors/patterns.ts+++ b/packages/model-runtime/src/errors/patterns.ts@@ -122,7 +122,6 @@ export const ERROR_PATTERNS: ErrorPattern[] = [match: sub('content exceeds maximum length of 100KB'),},{ code: AgentRuntimeErrorType.ExceededContextWindow, match: sub('ๅ ่ดนAPI้ๅถๆจกๅ่พๅ ฅtokenๅฐไบ') },- { code: AgentRuntimeErrorType.ExceededContextWindow, match: sub('Request body too large') },{code: AgentRuntimeErrorType.ExceededContextWindow,match: sub('conversation is too long'),@@ -133,6 +132,12 @@ export const ERROR_PATTERNS: ErrorPattern[] = [match: sub('ไธไธๆๅทฒ็ปๅ จ้ๅฏ็จ'),note: 'proxy gates 1m context โ request overflowed the default window',},+ {+ code: AgentRuntimeErrorType.ExceededContextWindow,+ match: sub("the model's context length"),+ note: 'OpenAI-style: passed N input + requested M output > context length',+ },+ { code: AgentRuntimeErrorType.ExceededContextWindow, match: sub('input tokens and requested') },// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ// InsufficientQuota โ account balance / billing exhausted (long-term)@@ -141,6 +146,12 @@ export const ERROR_PATTERNS: ErrorPattern[] = [code: AgentRuntimeErrorType.InsufficientQuota,match: sub('insufficient balance', { caseInsensitive: true }),},+ {+ code: AgentRuntimeErrorType.InsufficientQuota,+ match: sub('unavailable for free. The paid version'),+ },+ { code: AgentRuntimeErrorType.InsufficientQuota, match: sub('used all available credits') },+ { code: AgentRuntimeErrorType.InsufficientQuota, match: sub('CodingPlan subscription') },{code: AgentRuntimeErrorType.InsufficientQuota,match: sub('insufficient quota', { caseInsensitive: true }),@@ -531,6 +542,7 @@ export const ERROR_PATTERNS: ErrorPattern[] = [// generic "Connection error." surfaces on the top-level message.match: sub('Connection error.'),},+ { code: AgentRuntimeErrorType.ProviderNetworkError, match: sub('fetch failed') },// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ// StateStoreReadError โ a state-store READ failed: either a blocking read@@ -660,6 +672,11 @@ export const ERROR_PATTERNS: ErrorPattern[] = [{ code: AgentRuntimeErrorType.ModelNotFound, match: sub('ไฝ ่ฏทๆฑ็ๆจกๅ') },{ code: AgentRuntimeErrorType.ModelNotFound, match: sub('ไธๅญๅจๆๆชไธ็บฟ') },{ code: AgentRuntimeErrorType.ModelNotFound, match: sub('has no provider supported') },+ { code: AgentRuntimeErrorType.ModelNotFound, match: sub('model identifier is invalid') },+ { code: AgentRuntimeErrorType.ModelNotFound, match: sub('Incorrect model ID') },+ { code: AgentRuntimeErrorType.ModelNotFound, match: sub('not available for integrator') },+ { code: AgentRuntimeErrorType.ModelNotFound, match: sub('is not available. Please use') },+ { code: AgentRuntimeErrorType.ModelNotFound, match: sub('The requested model is not available') },// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ// InvalidProviderAPIKey@@ -735,6 +752,12 @@ export const ERROR_PATTERNS: ErrorPattern[] = [note: 'proxy restricts the group to Codex clients',},{ code: AgentRuntimeErrorType.PermissionDenied, match: sub('not available for trial users') },+ { code: AgentRuntimeErrorType.PermissionDenied, match: sub('403 Forbidden') },+ {+ code: AgentRuntimeErrorType.PermissionDenied,+ match: sub('Access denied due to Virtual Network'),+ },+ { code: AgentRuntimeErrorType.PermissionDenied, match: sub('does not allow the current client') },// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ// AccountDeactivated@@ -760,6 +783,11 @@ export const ERROR_PATTERNS: ErrorPattern[] = [// CapabilityNotSupported// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{ code: AgentRuntimeErrorType.CapabilityNotSupported, match: sub('not implemented') },+ {+ code: AgentRuntimeErrorType.CapabilityNotSupported,+ match: sub('Image inference is not supported on this endpoint'),+ },+ { code: AgentRuntimeErrorType.CapabilityNotSupported, match: sub('ไธๆฏๆSSE่ฐ็จๆนๅผ') },{ code: AgentRuntimeErrorType.CapabilityNotSupported, match: sub('The model is not a VLM') },{ code: AgentRuntimeErrorType.CapabilityNotSupported, match: sub('is not a multimodal model') },{@@ -966,6 +994,31 @@ export const ERROR_PATTERNS: ErrorPattern[] = [},{ code: AgentRuntimeErrorType.InvalidRequestFormat, match: sub('max_tokens must be at least') },{ code: AgentRuntimeErrorType.InvalidRequestFormat, match: sub('Yรชu cแบงu khรดng hแปฃp lแป') },+ // More malformed/oversized-request rejections harvested from the+ // UpstreamHttpError residue โ provider-side validation + custom-proxy schema+ // bridges, all upstream-side.+ { code: AgentRuntimeErrorType.InvalidRequestFormat, match: sub('allowed: adaptive, disabled') },+ {+ code: AgentRuntimeErrorType.InvalidRequestFormat,+ match: sub('invalid thinking: only type=enabled'),+ },+ {+ code: AgentRuntimeErrorType.InvalidRequestFormat,+ match: sub('Request contains an invalid argument'),+ },+ { code: AgentRuntimeErrorType.InvalidRequestFormat, match: sub("Input should be 'enabled'") },+ { code: AgentRuntimeErrorType.InvalidRequestFormat, match: sub('ๅๆฐ้ๆณใ่ฏทๆฃๆฅๆๆกฃ') },+ { code: AgentRuntimeErrorType.InvalidRequestFormat, match: sub('"code":"BAD_REQUEST') },+ { code: AgentRuntimeErrorType.InvalidRequestFormat, match: sub('Field required') },+ { code: AgentRuntimeErrorType.InvalidRequestFormat, match: sub('invalid image detail') },+ { code: AgentRuntimeErrorType.InvalidRequestFormat, match: sub('field MaxTokens invalid') },+ { code: AgentRuntimeErrorType.InvalidRequestFormat, match: sub('field ReasoningEffort invalid') },+ { code: AgentRuntimeErrorType.InvalidRequestFormat, match: sub('request validation errors') },+ {+ code: AgentRuntimeErrorType.InvalidRequestFormat,+ match: sub('function_declarations'),+ note: 'custom gemini proxies mangle tool schema; lobehub-native schema bug fixed in #14740',+ },// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ// UserConfigError@@ -998,6 +1051,11 @@ export const ERROR_PATTERNS: ErrorPattern[] = [code: AgentRuntimeErrorType.UserConfigError,match: sub('is not allowed for this virtual key'),},+ // Endpoint / base-URL misconfiguration: upstream returns a routing 404 for a+ // path the user's proxy config never exposed.+ { code: AgentRuntimeErrorType.UserConfigError, match: sub('page not found') },+ { code: AgentRuntimeErrorType.UserConfigError, match: sub('No route for that URI') },+ { code: AgentRuntimeErrorType.UserConfigError, match: sub('url.not_found') },// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ// UpstreamGatewayError โ proxy / gateway-layer failure (openresty, litellm,@@ -1017,6 +1075,11 @@ export const ERROR_PATTERNS: ErrorPattern[] = [match: sub('525 <!DOCTYPE html>'),note: 'Cloudflare 525 SSL handshake',},+ {+ code: AgentRuntimeErrorType.UpstreamGatewayError,+ match: sub('<!doctype html', { caseInsensitive: true }),+ note: 'bare HTML error body from a proxy/gateway (no status prefix)',+ },// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ// UpstreamMalformedResponse โ provider returned a malformed / unparseable