fix: retry evicted agentrun projection resume
This commit is contained in:
@@ -1683,9 +1683,11 @@ function agentRunProjectionResumeCandidate(session = {}, record = {}, { minAgeMs
|
||||
const threadId = safeOpaqueId(record.threadId ?? session.threadId) || null;
|
||||
const ownerUserId = textValue(record.ownerUserId ?? session.ownerUserId);
|
||||
const ownerRole = textValue(record.ownerRole ?? session.ownerRole) || "user";
|
||||
const retryParams = agentRunProjectionRetryParams(record.retryParams ?? record.projectionRetryParams ?? session.retryParams);
|
||||
return {
|
||||
traceId,
|
||||
params: {
|
||||
...retryParams,
|
||||
traceId,
|
||||
sessionId,
|
||||
conversationId,
|
||||
@@ -1731,9 +1733,11 @@ function agentRunProjectionResumeCandidateFromState(state = {}, { minAgeMs = DEF
|
||||
const ownerUserId = textValue(state.ownerUserId);
|
||||
const ownerRole = textValue(state.ownerRole) || "user";
|
||||
const lastSeq = Number.isFinite(Number(state.lastSourceSeq ?? state.lastAgentRunSeq)) ? Number(state.lastSourceSeq ?? state.lastAgentRunSeq) : 0;
|
||||
const retryParams = agentRunProjectionRetryParams(state.retryParams ?? state.projectionRetryParams);
|
||||
return {
|
||||
traceId,
|
||||
params: {
|
||||
...retryParams,
|
||||
traceId,
|
||||
sessionId,
|
||||
conversationId,
|
||||
@@ -1772,6 +1776,29 @@ function agentRunProjectionResumeCandidateFromState(state = {}, { minAgeMs = DEF
|
||||
};
|
||||
}
|
||||
|
||||
function agentRunProjectionRetryParams(value = null) {
|
||||
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
||||
const message = textValue(value.message ?? value.prompt ?? value.text);
|
||||
if (!message) return {};
|
||||
const result = {
|
||||
message,
|
||||
prompt: message,
|
||||
text: message,
|
||||
projectId: textValue(value.projectId) || undefined,
|
||||
ownerUserId: textValue(value.ownerUserId) || undefined,
|
||||
ownerRole: textValue(value.ownerRole) || undefined,
|
||||
providerProfile: textValue(value.providerProfile ?? value.codeAgentProviderProfile ?? value.backendProfile) || undefined,
|
||||
codeAgentProviderProfile: textValue(value.codeAgentProviderProfile ?? value.providerProfile ?? value.backendProfile) || undefined,
|
||||
backendProfile: textValue(value.backendProfile ?? value.providerProfile ?? value.codeAgentProviderProfile) || undefined,
|
||||
providerId: textValue(value.providerId) || undefined,
|
||||
valuesPrinted: false
|
||||
};
|
||||
for (const [key, item] of Object.entries(result)) {
|
||||
if (item === undefined || item === "") delete result[key];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
async function resumeAgentRunProjectionCandidate({ candidate, options = {}, traceStore = defaultCodeAgentTraceStore } = {}) {
|
||||
const { currentResult } = await agentRunProjectionResumeResultWithCursor(candidate, options);
|
||||
const resumeOptions = { ...options, deferAgentRunResultSync: false };
|
||||
@@ -1781,7 +1808,8 @@ async function resumeAgentRunProjectionCandidate({ candidate, options = {}, trac
|
||||
options: resumeOptions,
|
||||
traceStore,
|
||||
forceResultSync: true,
|
||||
refreshEvents: true
|
||||
refreshEvents: true,
|
||||
retryParams: candidate.params
|
||||
});
|
||||
const payload = codeAgentPayloadWithObservedTerminalStatus(synced?.result ?? currentResult, synced?.runnerTrace ?? traceStore?.snapshot?.(candidate.traceId)) ?? (synced?.result ?? currentResult);
|
||||
if (isTraceCommandTerminalStatus(payload?.status)) {
|
||||
|
||||
Reference in New Issue
Block a user