diff --git a/src/agents/pi-settings.test.ts b/src/agents/pi-settings.test.ts index 608bc2f80c0..600e2d4385c 100644 --- a/src/agents/pi-settings.test.ts +++ b/src/agents/pi-settings.test.ts @@ -377,15 +377,25 @@ describe("isSilentOverflowProneModel", () => { // openclaw#75799 reporter's setup: an OpenAI-compatible in-house gateway // exposing Zhipu's GLM family directly (model id `glm-5.1`, no `z-ai/` - // qualifier, custom baseUrl that is not api.z.ai). Catch the GLM family - // name with or without a path namespace so deploys that proxy it under - // their own provider name still hit the guard. - it("flags glm- model ids regardless of path namespace", () => { + // qualifier, custom baseUrl that is not api.z.ai). Catch the bare GLM + // family name so direct gateway deployments hit the guard. + it("flags bare glm- model ids without a namespace prefix", () => { expect(isSilentOverflowProneModel({ provider: "custom", modelId: "glm-5.1" })).toBe(true); expect(isSilentOverflowProneModel({ provider: "custom", modelId: "glm-4.7" })).toBe(true); + }); + + // Detection is intentionally narrow to z.ai-style accounting. Namespaced GLM + // ids that route through providers with their own overflow accounting must + // NOT be flagged — those hosts may not exhibit the z.ai silent-overflow + // shape, and disabling Pi auto-compaction for them would over-broaden the + // kill surface beyond the reproducible repro. + it("does not flag namespaced GLM ids routed through non-z.ai hosts", () => { expect( isSilentOverflowProneModel({ provider: "ollama", modelId: "ollama/glm-5.1:cloud" }), - ).toBe(true); + ).toBe(false); + expect( + isSilentOverflowProneModel({ provider: "opencode-go", modelId: "opencode-go/glm-5.1" }), + ).toBe(false); }); // pi-ai's overflow.ts only documents z.ai as the silent-overflow style. We diff --git a/src/agents/pi-settings.ts b/src/agents/pi-settings.ts index 3c64ccf72a7..4daedcad832 100644 --- a/src/agents/pi-settings.ts +++ b/src/agents/pi-settings.ts @@ -131,12 +131,14 @@ export function applyPiCompactionSettingsFromConfig(params: { * provider call (openclaw#75799). * * True on any of: `zai-native` endpoint class, normalized provider id `zai`, - * a `z-ai/` / `openrouter/z-ai/` model-id namespace prefix, or a `glm-` model - * name (with or without a path namespace) — covering in-house gateways and - * ollama-style deploys that expose Zhipu's GLM family directly without a - * `z-ai/` qualifier. Intentionally narrow to z.ai-style accounting; other - * providers documented as silently truncating are not added without a - * reproducible repro. + * a `z-ai/` / `openrouter/z-ai/` model-id namespace prefix, or a bare `glm-` + * model id (no namespace prefix) — the latter covers in-house gateways that + * expose Zhipu's GLM family directly without a `z-ai/` qualifier. Intentionally + * narrow: namespaced GLM ids that route through other providers (e.g. + * `ollama/glm-*`, `opencode-go/glm-*`) are NOT included because their hosts + * have their own overflow accounting and may not exhibit the z.ai silent- + * overflow shape. Other providers documented as silently truncating are not + * added without a reproducible repro. */ export function isSilentOverflowProneModel(model: { provider?: string | null; @@ -157,8 +159,7 @@ export function isSilentOverflowProneModel(model: { if ( normalized.startsWith("z-ai/") || normalized.startsWith("openrouter/z-ai/") || - normalized.startsWith("glm-") || - normalized.includes("/glm-") + normalized.startsWith("glm-") ) { return true; }