fix: retry evicted agentrun projection resume

This commit is contained in:
root
2026-06-29 17:17:42 +00:00
parent b2d2642b5b
commit 4ed8db2c00
5 changed files with 289 additions and 4 deletions
@@ -696,6 +696,7 @@ export async function syncAgentRunChatResult({ traceId, currentResult = null, op
const managerUrl = resolveAgentRunManagerUrl(env, mapped.agentRun.managerUrl);
const timeoutMs = parsePositiveInteger(env.HWLAB_CODE_AGENT_AGENTRUN_HTTP_TIMEOUT_MS, 20_000);
const projectionState = await loadWorkbenchProjectionStateForAgentRun(options.runtimeStore, { traceId, agentRun: mapped.agentRun });
const projectionRetryParams = retryParams ?? projectionState?.retryParams ?? null;
const fetchPlan = buildAgentRunProjectionEventsFetchPlan({
projectionState,
agentRun: mapped.agentRun,
@@ -714,6 +715,7 @@ export async function syncAgentRunChatResult({ traceId, currentResult = null, op
eventsResponse,
resultSyncState: terminalFromEvents ? "pending" : null,
projectionStatus: terminalFromEvents ? "terminal" : null,
retryParams: projectionRetryParams,
now: options.now
});
const deferResultSync = agentRunResultSyncDeferred({ forceResultSync, options, env });
@@ -744,6 +746,7 @@ export async function syncAgentRunChatResult({ traceId, currentResult = null, op
eventsResponse,
resultSyncState: agentRunMetricStatusForError(error) === "timeout" ? "timed_out" : "failed",
projectionStatus: terminalFromEvents ? "terminal" : null,
retryParams: projectionRetryParams,
error,
now: options.now
});
@@ -761,7 +764,7 @@ export async function syncAgentRunChatResult({ traceId, currentResult = null, op
valuesPrinted: false
});
const freshSessionRetry = await retryAgentRunTurnAfterFreshSessionFailure({
params: retryParams,
params: projectionRetryParams,
options,
traceId,
traceStore,
@@ -783,6 +786,7 @@ export async function syncAgentRunChatResult({ traceId, currentResult = null, op
eventsResponse: null,
resultSyncState: null,
projectionStatus: "projecting",
retryParams: projectionRetryParams,
now: options.now
});
return { result: freshSessionRetry.payload, runnerTrace: freshSessionRetry.payload.runnerTrace ?? traceStore.snapshot(traceId), found: true, eventsRefreshed: Boolean(eventsResponse), resultSynced: false, freshSessionRetried: true };
@@ -797,6 +801,7 @@ export async function syncAgentRunChatResult({ traceId, currentResult = null, op
eventsResponse,
resultSyncState: "synced",
projectionStatus: isAgentRunTerminalStatus(payload?.status) ? "terminal" : null,
retryParams: projectionRetryParams,
now: options.now
});
return { result: payload, runnerTrace: payload.runnerTrace ?? traceStore.snapshot(traceId), found: true, eventsRefreshed: Boolean(eventsResponse), resultSynced: true };