
























@@ -171,6 +171,8 @@ const MAX_SAME_MODEL_IDLE_TIMEOUT_RETRIES = 1;
171171const EMBEDDED_RUN_LANE_TIMEOUT_GRACE_MS = 30_000;
172172const MID_TURN_PRECHECK_CONTINUATION_PROMPT =
173173"Continue from the current transcript after the latest tool result. Do not repeat the original user request, and do not rerun completed tools unless the transcript shows they are still needed.";
174+const COMPACTION_CONTINUATION_RETRY_INSTRUCTION =
175+"The previous attempt compacted the conversation context before producing a final user-visible answer. Continue from the compacted transcript and produce the final answer now. Do not restart from scratch, do not repeat completed work, and do not rerun tools unless the transcript clearly lacks required evidence.";
174176type EmbeddedRunAttemptForRunner = Awaited<ReturnType<typeof runEmbeddedAttemptWithBackend>>;
175177176178function resolveEmbeddedRunLaneTimeoutMs(timeoutMs: number): number | undefined {
@@ -769,6 +771,7 @@ export async function runEmbeddedPiAgent(
769771let planningOnlyRetryAttempts = 0;
770772let reasoningOnlyRetryAttempts = 0;
771773let emptyResponseRetryAttempts = 0;
774+let compactionContinuationRetryAttempts = 0;
772775let sameModelIdleTimeoutRetries = 0;
773776// Cost-runaway breaker for #76293. State lives at the run-loop level
774777// on purpose so it survives across attempt boundaries and across
@@ -781,6 +784,7 @@ export async function runEmbeddedPiAgent(
781784let planningOnlyRetryInstruction: string | null = null;
782785let reasoningOnlyRetryInstruction: string | null = null;
783786let emptyResponseRetryInstruction: string | null = null;
787+let compactionContinuationRetryInstruction: string | null = null;
784788let nextAttemptPromptOverride: string | null = null;
785789const ackExecutionFastPathInstruction = resolveAckExecutionFastPathInstruction({
786790 provider,
@@ -996,6 +1000,7 @@ export async function runEmbeddedPiAgent(
9961000planningOnlyRetryInstruction,
9971001reasoningOnlyRetryInstruction,
9981002emptyResponseRetryInstruction,
1003+compactionContinuationRetryInstruction,
9991004].filter(
10001005(value): value is string => typeof value === "string" && value.trim().length > 0,
10011006);
@@ -2347,6 +2352,29 @@ export async function runEmbeddedPiAgent(
23472352 timedOut,
23482353 attempt,
23492354});
2355+if (
2356+!emptyAssistantReplyIsSilent &&
2357+attemptCompactionCount > 0 &&
2358+payloadCount === 0 &&
2359+!aborted &&
2360+!promptError &&
2361+!timedOut &&
2362+!attempt.clientToolCalls &&
2363+!attempt.yieldDetected &&
2364+!attempt.didSendDeterministicApprovalPrompt &&
2365+!attempt.lastToolError &&
2366+!hasMessagingToolDeliveryEvidence(attempt) &&
2367+compactionContinuationRetryAttempts < 1
2368+) {
2369+compactionContinuationRetryAttempts += 1;
2370+compactionContinuationRetryInstruction = COMPACTION_CONTINUATION_RETRY_INSTRUCTION;
2371+log.warn(
2372+`compaction interrupted visible final answer: runId=${params.runId} sessionId=${params.sessionId} ` +
2373+`compactions=${attemptCompactionCount} — retrying ${compactionContinuationRetryAttempts}/1 with compacted-transcript continuation`,
2374+);
2375+continue;
2376+}
2377+compactionContinuationRetryInstruction = null;
23502378if (reasoningOnlyRetriesExhausted && !finalAssistantVisibleText) {
23512379log.warn(
23522380`reasoning-only retries exhausted: runId=${params.runId} sessionId=${params.sessionId} ` +
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。