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

推荐订阅源

N
Netflix TechBlog - Medium
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
F
Fortinet All Blogs
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Stack Overflow Blog
Stack Overflow Blog
人人都是产品经理
人人都是产品经理
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
LangChain Blog
Microsoft Security Blog
Microsoft Security Blog
Apple Machine Learning Research
Apple Machine Learning Research
Y
Y Combinator Blog
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
IT之家
IT之家
V
V2EX
C
Check Point Blog
MongoDB | Blog
MongoDB | Blog
Last Week in AI
Last Week in AI
B
Blog
J
Java Code Geeks
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网

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(compaction): ignore metadata bytes in preflight press...
amknight · 2026-05-07 · via Recent Commits to openclaw:main

@@ -596,6 +596,189 @@ describe("runMemoryFlushIfNeeded", () => {

596596

expect(compactCall.currentTokenCount).toBeGreaterThan(100_000);

597597

});

598598599+

it("combines latest usage with post-usage tail pressure for preflight compaction", async () => {

600+

const sessionFile = path.join(rootDir, "combined-tail-pressure-session.jsonl");

601+

await fs.writeFile(

602+

sessionFile,

603+

[

604+

JSON.stringify({

605+

message: {

606+

role: "assistant",

607+

content: "small answer",

608+

usage: { input: 86_000, output: 2_000 },

609+

},

610+

}),

611+

JSON.stringify({

612+

message: {

613+

role: "tool",

614+

content: `moderate interrupted tool output ${"x".repeat(36_000)}`,

615+

},

616+

}),

617+

].join("\n"),

618+

"utf8",

619+

);

620+

registerMemoryFlushPlanResolverForTest(() => ({

621+

softThresholdTokens: 4_000,

622+

forceFlushTranscriptBytes: 1_000_000_000,

623+

reserveTokensFloor: 0,

624+

prompt: "Pre-compaction memory flush.\nNO_REPLY",

625+

systemPrompt: "Write memory to memory/YYYY-MM-DD.md.",

626+

relativePath: "memory/2023-11-14.md",

627+

}));

628+

const sessionEntry: SessionEntry = {

629+

sessionId: "session",

630+

sessionFile,

631+

updatedAt: Date.now(),

632+

totalTokensFresh: false,

633+

};

634+635+

await runPreflightCompactionIfNeeded({

636+

cfg: { agents: { defaults: { compaction: { memoryFlush: {} } } } },

637+

followupRun: createTestFollowupRun({

638+

sessionId: "session",

639+

sessionFile,

640+

sessionKey: "main",

641+

}),

642+

defaultModel: "anthropic/claude-opus-4-6",

643+

agentCfgContextTokens: 100_000,

644+

sessionEntry,

645+

sessionStore: { main: sessionEntry },

646+

sessionKey: "main",

647+

storePath: path.join(rootDir, "sessions.json"),

648+

isHeartbeat: false,

649+

replyOperation: createReplyOperation(),

650+

});

651+652+

const compactCall = compactEmbeddedPiSessionMock.mock.calls[0]?.[0] as {

653+

currentTokenCount?: number;

654+

};

655+

expect(compactCall.currentTokenCount).toBeGreaterThanOrEqual(96_000);

656+

});

657+658+

it("does not count bytes from a large latest usage record as post-usage tail pressure", async () => {

659+

const sessionFile = path.join(rootDir, "large-usage-record-session.jsonl");

660+

await fs.writeFile(

661+

sessionFile,

662+

[

663+

JSON.stringify({

664+

type: "session",

665+

id: "session",

666+

}),

667+

JSON.stringify({

668+

message: {

669+

role: "assistant",

670+

content: `large answer ${"x".repeat(300_000)}`,

671+

usage: { input: 40_000, output: 2_000 },

672+

},

673+

}),

674+

].join("\n"),

675+

"utf8",

676+

);

677+

registerMemoryFlushPlanResolverForTest(() => ({

678+

softThresholdTokens: 4_000,

679+

forceFlushTranscriptBytes: 1_000_000_000,

680+

reserveTokensFloor: 0,

681+

prompt: "Pre-compaction memory flush.\nNO_REPLY",

682+

systemPrompt: "Write memory to memory/YYYY-MM-DD.md.",

683+

relativePath: "memory/2023-11-14.md",

684+

}));

685+

const sessionEntry: SessionEntry = {

686+

sessionId: "session",

687+

sessionFile,

688+

updatedAt: Date.now(),

689+

totalTokensFresh: false,

690+

};

691+692+

const entry = await runPreflightCompactionIfNeeded({

693+

cfg: { agents: { defaults: { compaction: { memoryFlush: {} } } } },

694+

followupRun: createTestFollowupRun({

695+

sessionId: "session",

696+

sessionFile,

697+

sessionKey: "main",

698+

}),

699+

defaultModel: "anthropic/claude-opus-4-6",

700+

agentCfgContextTokens: 100_000,

701+

sessionEntry,

702+

sessionStore: { main: sessionEntry },

703+

sessionKey: "main",

704+

storePath: path.join(rootDir, "sessions.json"),

705+

isHeartbeat: false,

706+

replyOperation: createReplyOperation(),

707+

});

708+709+

expect(entry).toBe(sessionEntry);

710+

expect(compactEmbeddedPiSessionMock).not.toHaveBeenCalled();

711+

});

712+713+

it("does not treat raw transcript metadata bytes as token pressure", async () => {

714+

const sessionFile = path.join(rootDir, "metadata-heavy-session.jsonl");

715+

await fs.writeFile(

716+

sessionFile,

717+

[

718+

JSON.stringify({

719+

type: "session",

720+

id: "session",

721+

}),

722+

JSON.stringify({

723+

type: "custom",

724+

payload: "x".repeat(450_000),

725+

}),

726+

JSON.stringify({

727+

message: {

728+

role: "assistant",

729+

content: "small answer",

730+

usage: { input: 40_000, output: 2_000 },

731+

},

732+

}),

733+

].join("\n"),

734+

"utf8",

735+

);

736+

registerMemoryFlushPlanResolverForTest(() => ({

737+

softThresholdTokens: 4_000,

738+

forceFlushTranscriptBytes: 1_000_000_000,

739+

reserveTokensFloor: 0,

740+

prompt: "Pre-compaction memory flush.\nNO_REPLY",

741+

systemPrompt: "Write memory to memory/YYYY-MM-DD.md.",

742+

relativePath: "memory/2023-11-14.md",

743+

}));

744+

const sessionEntry: SessionEntry = {

745+

sessionId: "session",

746+

sessionFile,

747+

updatedAt: Date.now(),

748+

totalTokensFresh: false,

749+

};

750+751+

const entry = await runPreflightCompactionIfNeeded({

752+

cfg: {

753+

agents: {

754+

defaults: {

755+

compaction: {

756+

memoryFlush: {},

757+

truncateAfterCompaction: true,

758+

maxActiveTranscriptBytes: "10mb",

759+

},

760+

},

761+

},

762+

},

763+

followupRun: createTestFollowupRun({

764+

sessionId: "session",

765+

sessionFile,

766+

sessionKey: "main",

767+

}),

768+

defaultModel: "anthropic/claude-opus-4-6",

769+

agentCfgContextTokens: 100_000,

770+

sessionEntry,

771+

sessionStore: { main: sessionEntry },

772+

sessionKey: "main",

773+

storePath: path.join(rootDir, "sessions.json"),

774+

isHeartbeat: false,

775+

replyOperation: createReplyOperation(),

776+

});

777+778+

expect(entry).toBe(sessionEntry);

779+

expect(compactEmbeddedPiSessionMock).not.toHaveBeenCalled();

780+

});

781+599782

it("triggers preflight compaction when the active transcript exceeds the configured byte threshold", async () => {

600783

const sessionFile = path.join(rootDir, "large-session.jsonl");

601784

await fs.writeFile(