惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
Vercel News
Vercel News
M
MIT News - Artificial intelligence
L
LangChain Blog
大猫的无限游戏
大猫的无限游戏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Azure Blog
Microsoft Azure Blog
J
Java Code Geeks
Recent Announcements
Recent Announcements
Stack Overflow Blog
Stack Overflow Blog
人人都是产品经理
人人都是产品经理
IT之家
IT之家
F
Fortinet All Blogs
博客园 - 聂微东
U
Unit 42
Martin Fowler
Martin Fowler
腾讯CDC
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
量子位
阮一峰的网络日志
阮一峰的网络日志
博客园 - Franky

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: disable Pi auto-compaction when safeguard mode is ac...
bradhallett · 2026-05-06 · via Recent Commits to openclaw:main

@@ -5,7 +5,9 @@ import {

55

applyPiCompactionSettingsFromConfig,

66

DEFAULT_PI_COMPACTION_RESERVE_TOKENS_FLOOR,

77

isSilentOverflowProneModel,

8+

resolveEffectiveCompactionMode,

89

resolveCompactionReserveTokensFloor,

10+

shouldDisablePiAutoCompaction,

911

} from "./pi-settings.js";

10121113

describe("applyPiCompactionSettingsFromConfig", () => {

@@ -347,6 +349,40 @@ describe("resolveCompactionReserveTokensFloor", () => {

347349

).toBe(0);

348350

});

349351

});

352+

describe("resolveEffectiveCompactionMode", () => {

353+

it("defaults to default compaction mode", () => {

354+

expect(resolveEffectiveCompactionMode()).toBe("default");

355+

expect(resolveEffectiveCompactionMode({ agents: { defaults: { compaction: {} } } })).toBe(

356+

"default",

357+

);

358+

expect(

359+

resolveEffectiveCompactionMode({

360+

agents: { defaults: { compaction: { mode: "default" } } },

361+

}),

362+

).toBe("default");

363+

});

364+365+

it("returns safeguard for explicit safeguard mode", () => {

366+

expect(

367+

resolveEffectiveCompactionMode({

368+

agents: { defaults: { compaction: { mode: "safeguard" } } },

369+

}),

370+

).toBe("safeguard");

371+

});

372+373+

it("returns safeguard when a compaction provider is configured", () => {

374+

expect(

375+

resolveEffectiveCompactionMode({

376+

agents: { defaults: { compaction: { provider: "deepseek" } } },

377+

}),

378+

).toBe("safeguard");

379+

expect(

380+

resolveEffectiveCompactionMode({

381+

agents: { defaults: { compaction: { mode: "default", provider: "deepseek" } } },

382+

}),

383+

).toBe("safeguard");

384+

});

385+

});

350386351387

describe("isSilentOverflowProneModel", () => {

352388

// Reporter's repro shape: openrouter routing to z-ai/glm. Both the bare

@@ -432,6 +468,36 @@ describe("isSilentOverflowProneModel", () => {

432468

});

433469

});

434470471+

describe("shouldDisablePiAutoCompaction", () => {

472+

it("returns false with no owner, default mode, and ordinary provider behavior", () => {

473+

expect(shouldDisablePiAutoCompaction({})).toBe(false);

474+

expect(shouldDisablePiAutoCompaction({ compactionMode: "default" })).toBe(false);

475+

expect(

476+

shouldDisablePiAutoCompaction({

477+

contextEngineInfo: { id: "legacy", name: "Legacy", ownsCompaction: false },

478+

compactionMode: "default",

479+

silentOverflowProneProvider: false,

480+

}),

481+

).toBe(false);

482+

});

483+484+

it("returns true when a context engine owns compaction", () => {

485+

expect(

486+

shouldDisablePiAutoCompaction({

487+

contextEngineInfo: { id: "third-party", name: "Third-party", ownsCompaction: true },

488+

}),

489+

).toBe(true);

490+

});

491+492+

it("returns true when effective compaction mode is safeguard", () => {

493+

expect(shouldDisablePiAutoCompaction({ compactionMode: "safeguard" })).toBe(true);

494+

});

495+496+

it("returns true for silent-overflow-prone providers", () => {

497+

expect(shouldDisablePiAutoCompaction({ silentOverflowProneProvider: true })).toBe(true);

498+

});

499+

});

500+435501

describe("applyPiAutoCompactionGuard", () => {

436502

// Direct repro of openclaw#75799: pi-ai's silent-overflow detection misfires

437503

// on a successful turn against z.ai-style providers, triggering Pi's

@@ -481,6 +547,26 @@ describe("applyPiAutoCompactionGuard", () => {

481547

expect(setCompactionEnabled).toHaveBeenCalledWith(false);

482548

});

483549550+

it("disables Pi auto-compaction when provider config forces safeguard mode", () => {

551+

const setCompactionEnabled = vi.fn();

552+

const settingsManager = {

553+

getCompactionReserveTokens: () => 20_000,

554+

getCompactionKeepRecentTokens: () => 4_000,

555+

applyOverrides: () => {},

556+

setCompactionEnabled,

557+

};

558+559+

const result = applyPiAutoCompactionGuard({

560+

settingsManager,

561+

compactionMode: resolveEffectiveCompactionMode({

562+

agents: { defaults: { compaction: { provider: "deepseek" } } },

563+

}),

564+

});

565+566+

expect(result).toEqual({ supported: true, disabled: true });

567+

expect(setCompactionEnabled).toHaveBeenCalledWith(false);

568+

});

569+484570

// Default-mode runs against ordinary providers must keep Pi's auto-compaction

485571

// enabled. Disabling it across the board would silently remove Pi's

486572

// overflow-recovery path inside Session.prompt() for users who are not