Skip to content

Commit 6c10413

Browse files
0xghost42steipete
andauthored
fix(agents): classify Zhipu GLM overload as overloaded for failover (#93241)
Merged via squash. Prepared head SHA: db79e94 Co-authored-by: 0xghost42 <[email protected]> Co-authored-by: steipete <[email protected]> Reviewed-by: @steipete
1 parent db54a32 commit 6c10413

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/agents/embedded-agent-helpers/failover-matches.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@ describe("Z.ai vendor error codes (#48988)", () => {
103103
});
104104
});
105105

106+
describe("Chinese provider overload messages", () => {
107+
const ZHIPU_OVERLOAD = "[1305][该模型当前访问量过大,请您稍后再试]";
108+
109+
it("classifies the Zhipu GLM overload body as overloaded", () => {
110+
expect(isOverloadedErrorMessage(ZHIPU_OVERLOAD)).toBe(true);
111+
});
112+
113+
it("does not misclassify the GLM overload body as rate limit or auth", () => {
114+
expect(isRateLimitErrorMessage(ZHIPU_OVERLOAD)).toBe(false);
115+
expect(isAuthErrorMessage(ZHIPU_OVERLOAD)).toBe(false);
116+
});
117+
});
118+
106119
describe("Volcengine Coding Plan subscription errors", () => {
107120
it("classifies InvalidSubscription JSON body as billing", () => {
108121
const raw =

src/agents/embedded-agent-helpers/failover-matches.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ const ERROR_PATTERNS = {
107107
// Chinese provider overloaded messages
108108
"服务过载",
109109
"当前负载过高",
110+
"访问量过大",
110111
],
111112
serverError: [
112113
"an error occurred while processing",

src/agents/model-fallback.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,24 @@ describe("runWithModelFallback", () => {
746746
expect(result.attempts[0].reason).toBe("unknown");
747747
});
748748

749+
it("falls back on a Zhipu GLM 1305 overload body and classifies it as overloaded", async () => {
750+
const cfg = makeCfg();
751+
const glmOverload = new Error("[1305][该模型当前访问量过大,请您稍后再试]");
752+
const run = vi.fn().mockRejectedValueOnce(glmOverload).mockResolvedValueOnce("ok");
753+
754+
const result = await runWithModelFallback({
755+
cfg,
756+
provider: "glm",
757+
model: "GLM-5.2",
758+
run,
759+
});
760+
expect(result.result).toBe("ok");
761+
expect(run).toHaveBeenCalledTimes(2);
762+
expect(requireMockCall(run, 1, "fallback run")).toEqual(["anthropic", "claude-haiku-3-5"]);
763+
expect(result.attempts).toHaveLength(1);
764+
expect(result.attempts[0].reason).toBe("overloaded");
765+
});
766+
749767
it("does not prepare agent harness plugins for forced OpenClaw candidates", async () => {
750768
const cfg = makeCfg({
751769
models: {

0 commit comments

Comments
 (0)