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

推荐订阅源

D
Docker
小众软件
小众软件
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - Franky
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
博客园 - 聂微东
S
SegmentFault 最新的问题
量子位
宝玉的分享
宝玉的分享
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页

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: move compaction planning off the event loop · opencl...
steipete · 2026-05-30 · via Recent Commits to openclaw:main

@@ -9,6 +9,10 @@ import {

99

getCompactionProvider,

1010

type CompactionProvider,

1111

} from "../../plugins/compaction-provider.js";

12+

import {

13+

buildHistoryPrunePlanWithWorker,

14+

computeAdaptiveChunkRatioWithWorker,

15+

} from "../compaction-planning-worker.js";

1216

import {

1317

hasMeaningfulConversationContent,

1418

isRealConversationMessage,

@@ -19,9 +23,7 @@ import {

1923

SAFETY_MARGIN,

2024

SUMMARIZATION_OVERHEAD_TOKENS,

2125

computeAdaptiveChunkRatio,

22-

estimateMessagesTokens,

2326

isOversizedForSummary,

24-

pruneHistoryForContextShare,

2527

resolveContextWindowTokens,

2628

summarizeInStages,

2729

} from "../compaction.js";

@@ -1071,19 +1073,18 @@ export default function compactionSafeguardExtension(api: ExtensionAPI): void {

10711073

let droppedSummary: string | undefined;

1072107410731075

if (tokensBefore !== undefined) {

1074-

const summarizableTokens =

1075-

estimateMessagesTokens(messagesToSummarize) + estimateMessagesTokens(turnPrefixMessages);

1076-

const newContentTokens = Math.max(0, Math.floor(tokensBefore - summarizableTokens));

1077-

// Apply SAFETY_MARGIN so token underestimates don't trigger unnecessary pruning

1078-

const maxHistoryTokens = Math.floor(contextWindowTokens * maxHistoryShare * SAFETY_MARGIN);

1079-1080-

if (newContentTokens > maxHistoryTokens) {

1081-

const pruned = pruneHistoryForContextShare({

1082-

messages: messagesToSummarize,

1083-

maxContextTokens: contextWindowTokens,

1084-

maxHistoryShare,

1085-

parts: 2,

1086-

});

1076+

const prunePlan = await buildHistoryPrunePlanWithWorker({

1077+

messagesToSummarize,

1078+

turnPrefixMessages,

1079+

tokensBefore,

1080+

contextWindowTokens,

1081+

maxHistoryShare,

1082+

parts: 2,

1083+

signal,

1084+

});

1085+

const { newContentTokens, maxHistoryTokens, pruned } = prunePlan;

1086+1087+

if (newContentTokens > maxHistoryTokens && pruned) {

10871088

if (pruned.droppedChunks > 0) {

10881089

const newContentRatio = (newContentTokens / contextWindowTokens) * 100;

10891090

log.warn(

@@ -1097,10 +1098,11 @@ export default function compactionSafeguardExtension(api: ExtensionAPI): void {

10971098

// Summarize dropped messages so context isn't lost

10981099

if (pruned.droppedMessagesList.length > 0) {

10991100

try {

1100-

const droppedChunkRatio = computeAdaptiveChunkRatio(

1101-

pruned.droppedMessagesList,

1102-

contextWindowTokens,

1103-

);

1101+

const droppedChunkRatio = await computeAdaptiveChunkRatioWithWorker({

1102+

messages: pruned.droppedMessagesList,

1103+

contextWindow: contextWindowTokens,

1104+

signal,

1105+

});

11041106

const droppedMaxChunkTokens = Math.max(

11051107

1,

11061108

Math.floor(contextWindowTokens * droppedChunkRatio) -

@@ -1155,7 +1157,11 @@ export default function compactionSafeguardExtension(api: ExtensionAPI): void {

11551157

// the summarization prompt, system prompt, previous summary, and reasoning budget

11561158

// that generateSummary adds on top of the serialized conversation chunk.

11571159

const allMessages = [...messagesToSummarize, ...turnPrefixMessages];

1158-

const adaptiveRatio = computeAdaptiveChunkRatio(allMessages, contextWindowTokens);

1160+

const adaptiveRatio = await computeAdaptiveChunkRatioWithWorker({

1161+

messages: allMessages,

1162+

contextWindow: contextWindowTokens,

1163+

signal,

1164+

});

11591165

const maxChunkTokens = Math.max(

11601166

1,

11611167

Math.floor(contextWindowTokens * adaptiveRatio) - SUMMARIZATION_OVERHEAD_TOKENS,