



















@@ -1889,12 +1889,20 @@ export async function runEmbeddedPiAgent(
18891889const errorText = contextOverflowError.text;
18901890const msgCount = attempt.messagesSnapshot?.length ?? 0;
18911891const observedOverflowTokens = extractObservedOverflowTokenCount(errorText);
1892+const overflowTokenCountForCompaction =
1893+observedOverflowTokens ??
1894+(ctxInfo.tokens > 0
1895+ ? // Confirmed overflow with an unparseable provider message still carries a
1896+// minimally over-budget count for compaction engines and diagnostics.
1897+ctxInfo.tokens + 1
1898+ : undefined);
18921899log.warn(
18931900`[context-overflow-diag] sessionKey=${params.sessionKey ?? params.sessionId} ` +
18941901`provider=${provider}/${modelId} source=${contextOverflowError.source} ` +
18951902`messages=${msgCount} sessionFile=${activeSessionFile} ` +
18961903`diagId=${overflowDiagId} compactionAttempts=${overflowCompactionAttempts} ` +
18971904`observedTokens=${observedOverflowTokens ?? "unknown"} ` +
1905+`compactionTokens=${overflowTokenCountForCompaction ?? "unknown"} ` +
18981906`error=${errorText.slice(0, 200)}`,
18991907);
19001908const isCompactionFailure = isCompactionFailureError(errorText);
@@ -1978,8 +1986,8 @@ export async function runEmbeddedPiAgent(
19781986 ...(attempt.promptCache ? { promptCache: attempt.promptCache } : {}),
19791987runId: params.runId,
19801988trigger: "overflow",
1981- ...(observedOverflowTokens !== undefined
1982- ? { currentTokenCount: observedOverflowTokens }
1989+ ...(overflowTokenCountForCompaction !== undefined
1990+ ? { currentTokenCount: overflowTokenCountForCompaction }
19831991 : {}),
19841992diagId: overflowDiagId,
19851993attempt: overflowCompactionAttempts,
@@ -1997,8 +2005,8 @@ export async function runEmbeddedPiAgent(
19972005sessionKey: params.sessionKey,
19982006sessionFile: activeSessionFile,
19992007tokenBudget: ctxInfo.tokens,
2000- ...(observedOverflowTokens !== undefined
2001- ? { currentTokenCount: observedOverflowTokens }
2008+ ...(overflowTokenCountForCompaction !== undefined
2009+ ? { currentTokenCount: overflowTokenCountForCompaction }
20022010 : {}),
20032011force: true,
20042012compactionTarget: "budget",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。