mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 01:31:23 +00:00
Compaction: ignore tool result details in oversized checks (#24057)
* Compaction: ignore tool result details in oversized checks * Tests/Compaction: type estimateTokens message callback
This commit is contained in:
@@ -152,7 +152,7 @@ export function computeAdaptiveChunkRatio(messages: AgentMessage[], contextWindo
|
||||
* If single message > 50% of context, it can't be summarized safely.
|
||||
*/
|
||||
export function isOversizedForSummary(msg: AgentMessage, contextWindow: number): boolean {
|
||||
const tokens = estimateTokens(msg) * SAFETY_MARGIN;
|
||||
const tokens = estimateCompactionMessageTokens(msg) * SAFETY_MARGIN;
|
||||
return tokens > contextWindow * 0.5;
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ export async function summarizeWithFallback(params: {
|
||||
for (const msg of messages) {
|
||||
if (isOversizedForSummary(msg, contextWindow)) {
|
||||
const role = (msg as { role?: string }).role ?? "message";
|
||||
const tokens = estimateTokens(msg);
|
||||
const tokens = estimateCompactionMessageTokens(msg);
|
||||
oversizedNotes.push(
|
||||
`[Large ${role} (~${Math.round(tokens / 1000)}K tokens) omitted from summary]`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user