fix(model-fallback): classify Codex usage-limit payloads (#95400) · openclaw/openclaw@b8f1961
jason-allen-
·
2026-06-23
·
via Recent Commits to openclaw:main
File tree
src/agents/embedded-agent-runner
| Original file line number | Diff line number | Diff line change |
|---|
@@ -72,6 +72,37 @@ describe("classifyEmbeddedAgentRunResultForModelFallback", () => {
|
72 | 72 | }); |
73 | 73 | }); |
74 | 74 | |
| 75 | +it("classifies Codex subscription usage-limit payloads as rate-limit fallback", () => { |
| 76 | +const errorText = |
| 77 | +"You've reached your Codex subscription usage limit. " + |
| 78 | +"Next reset in 32 minutes, Jun 20 at 3:44 PM EDT. " + |
| 79 | +"Wait until the reset time, use another Codex account if available, " + |
| 80 | +"or switch to another configured model/provider."; |
| 81 | + |
| 82 | +const result = classifyEmbeddedAgentRunResultForModelFallback({ |
| 83 | +provider: "openai", |
| 84 | +model: "gpt-5.5", |
| 85 | +result: { |
| 86 | +payloads: [ |
| 87 | +{ |
| 88 | +isError: true, |
| 89 | +text: errorText, |
| 90 | +}, |
| 91 | +], |
| 92 | +meta: { |
| 93 | +durationMs: 42, |
| 94 | +}, |
| 95 | +}, |
| 96 | +}); |
| 97 | + |
| 98 | +expect(result).toEqual({ |
| 99 | +message: "openai/gpt-5.5 ended with a provider error: " + errorText, |
| 100 | +reason: "rate_limit", |
| 101 | +code: "embedded_error_payload", |
| 102 | +rawError: errorText, |
| 103 | +}); |
| 104 | +}); |
| 105 | + |
75 | 106 | it("does not classify normal visible assistant output as fallback-worthy", () => { |
76 | 107 | const result = classifyEmbeddedAgentRunResultForModelFallback({ |
77 | 108 | provider: "claude-cli", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -150,7 +150,7 @@ function classifyHarnessResult(params: {
|
150 | 150 | function classifyBusinessDenialErrorPayloadReason( |
151 | 151 | errorText: string, |
152 | 152 | provider: string, |
153 | | -): Extract<FailoverReason, "auth" | "auth_permanent" | "billing"> | null { |
| 153 | +): Extract<FailoverReason, "auth" | "auth_permanent" | "billing" | "rate_limit"> | null { |
154 | 154 | if (!errorText.trim()) { |
155 | 155 | return null; |
156 | 156 | } |
@@ -159,6 +159,7 @@ function classifyBusinessDenialErrorPayloadReason(
|
159 | 159 | case "auth": |
160 | 160 | case "auth_permanent": |
161 | 161 | case "billing": |
| 162 | +case "rate_limit": |
162 | 163 | return failoverReason; |
163 | 164 | default: |
164 | 165 | return null; |
@@ -208,6 +209,13 @@ export function classifyEmbeddedAgentRunResultForModelFallback(params: {
|
208 | 209 | if (genericExternalFailureClassification) { |
209 | 210 | return genericExternalFailureClassification; |
210 | 211 | } |
| 212 | +if ( |
| 213 | +typeof params.result.meta.finalAssistantVisibleText === "string" && |
| 214 | +params.result.meta.finalAssistantVisibleText.trim().length > 0 && |
| 215 | +!isSilentReplyPayloadText(params.result.meta.finalAssistantVisibleText) |
| 216 | +) { |
| 217 | +return null; |
| 218 | +} |
211 | 219 | if ( |
212 | 220 | hasVisibleAgentPayload(params.result, { |
213 | 221 | includeErrorPayloads: false, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。