@@ -6,10 +6,10 @@ import {
66} from "../../agents/run-termination.js" ;
77import { createAbortError } from "../../infra/abort-signal.js" ;
88import {
9- BLOCKED_TOOL_CALL_ABORT_FLOOR_MS ,
109 getDiagnosticSessionActivitySnapshot ,
1110 markDiagnosticEmbeddedRunEnded ,
1211 markDiagnosticEmbeddedRunStarted ,
12+ resolveRunStaleThresholdMs ,
1313} from "../../logging/diagnostic-run-activity.js" ;
1414import { diagnosticLogger as diag } from "../../logging/diagnostic-runtime.js" ;
1515import type { UserTurnTranscriptRecorder } from "../../sessions/user-turn-transcript.types.js" ;
@@ -218,9 +218,6 @@ export const REPLY_RUN_IDLE_SETTLE_TIMEOUT_MS = 15_000;
218218// Terminal results must release the lane even if the owner never resumes.
219219// Without this, abort/failure can leave the session wedged until process restart.
220220export const REPLY_RUN_TERMINAL_SETTLE_TIMEOUT_MS = 60_000 ;
221- // Visible human turns may reclaim only runs with no real progress for this window.
222- // Timers and user-message injection never refresh activity; agent events do.
223- export const REPLY_RUN_STALE_TAKEOVER_MS = 10 * 60_000 ;
224221
225222export type ReplyOperationStaleReason = "terminal_unreleased" | "no_activity" | "stuck_recovery" ;
226223
@@ -886,25 +883,16 @@ export function expireStaleReplyRunBySessionId(
886883 return operation ? expireStaleReplyOperation ( operation , reason ) : false ;
887884}
888885
889- /**
890- * Effective staleness window for an operation. Quiet-but-alive tool phases get
891- * the diagnostic blocked-tool floor: a human message must not reclaim a healthy
892- * long tool that stuck recovery itself would not touch yet.
893- */
894- export function resolveReplyRunStaleThresholdMs ( operation : ReplyOperation ) : number {
886+ // lastActivityAtMs is refreshed by agent events only; timers and user-message
887+ // injection never refresh it, so quiet runs age toward reclaim.
888+ export function isReplyRunEvidenceStale ( operation : ReplyOperation ) : boolean {
895889 const activity = getDiagnosticSessionActivitySnapshot ( {
896890 sessionId : operation . sessionId ,
897891 sessionKey : operation . key ,
898892 } ) ;
899- return activity . activeWorkKind === "tool_call"
900- ? Math . max ( REPLY_RUN_STALE_TAKEOVER_MS , BLOCKED_TOOL_CALL_ABORT_FLOOR_MS )
901- : REPLY_RUN_STALE_TAKEOVER_MS ;
902- }
903-
904- export function isReplyRunEvidenceStale ( operation : ReplyOperation ) : boolean {
905893 return (
906894 ! operation . result &&
907- Date . now ( ) - operation . lastActivityAtMs > resolveReplyRunStaleThresholdMs ( operation )
895+ Date . now ( ) - operation . lastActivityAtMs > resolveRunStaleThresholdMs ( activity )
908896 ) ;
909897}
910898
0 commit comments