mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:40:43 +00:00
fix(agents): complete pi-settings mock in compact.hooks harness
This commit is contained in:
@@ -301,8 +301,10 @@ export async function loadCompactHooksHarness(): Promise<{
|
||||
}));
|
||||
|
||||
vi.doMock("../pi-settings.js", () => ({
|
||||
applyPiAutoCompactionGuard: vi.fn(() => ({ supported: true, disabled: false })),
|
||||
applyPiCompactionSettingsFromConfig: vi.fn(),
|
||||
ensurePiCompactionReserveTokens: vi.fn(),
|
||||
isSilentOverflowProneModel: vi.fn(() => false),
|
||||
resolveCompactionReserveTokensFloor: vi.fn(() => 0),
|
||||
}));
|
||||
|
||||
|
||||
@@ -973,6 +973,9 @@ async function compactEmbeddedPiSessionDirectOnce(
|
||||
cfg: params.config,
|
||||
contextTokenBudget: ctxInfo.tokens,
|
||||
});
|
||||
// contextEngineInfo is intentionally omitted: this guard runs inside the
|
||||
// compaction LLM session, which is not the user-facing agent session and
|
||||
// has no associated context engine.
|
||||
applyPiAutoCompactionGuard({
|
||||
settingsManager,
|
||||
silentOverflowProneProvider: isSilentOverflowProneModel({
|
||||
|
||||
@@ -378,10 +378,16 @@ 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 bare GLM
|
||||
// family name so direct gateway deployments hit the guard.
|
||||
it("flags bare glm- model ids without a namespace prefix", () => {
|
||||
// family name so direct gateway deployments hit the guard regardless of
|
||||
// what `provider` field the user picked — gateways relabel the upstream
|
||||
// identity, so `provider` here can be anything from `openai` to a custom
|
||||
// string. False positives only disable Pi's secondary compaction path;
|
||||
// OpenClaw's preemptive compaction continues to handle real overflow.
|
||||
it("flags bare glm- model ids without a namespace prefix, regardless of provider", () => {
|
||||
expect(isSilentOverflowProneModel({ provider: "custom", modelId: "glm-5.1" })).toBe(true);
|
||||
expect(isSilentOverflowProneModel({ provider: "custom", modelId: "glm-4.7" })).toBe(true);
|
||||
expect(isSilentOverflowProneModel({ provider: "openai", modelId: "glm-5.1" })).toBe(true);
|
||||
expect(isSilentOverflowProneModel({ provider: "openrouter", modelId: "glm-5.1" })).toBe(true);
|
||||
});
|
||||
|
||||
// Detection is intentionally narrow to z.ai-style accounting. Namespaced GLM
|
||||
|
||||
Reference in New Issue
Block a user