fix: keep workbench agent provider profile across recovery

This commit is contained in:
root
2026-06-29 18:02:56 +00:00
parent e02a339240
commit 4f0aef7751
3 changed files with 258 additions and 5 deletions
@@ -706,6 +706,14 @@ export async function syncAgentRunChatResult({ traceId, currentResult = null, op
const eventsResponse = refreshEvents ? await measuredAgentRunEventsFetch({ performanceStore, fetchImpl, managerUrl, timeoutMs, env, mapping: { ...mapped.agentRun, lastSeq: fetchPlan.afterSeq, afterSeqOverride: fetchPlan.afterSeq, eventsPageLimit: fetchPlan.limit, traceSummary: mapped.traceSummary } }) : null;
if (eventsResponse) appendAgentRunEventsToTrace(traceStore, traceId, eventsResponse.events, mapped.agentRun);
const nextLastSeq = eventsResponse ? agentRunTraceCursorSeq(eventsResponse, mapped.agentRun.lastSeq) : mapped.agentRun.lastSeq;
const backendProfile = resolveAgentRunBackendProfile(env, {
providerProfile: firstNonEmpty(
projectionRetryParams?.providerProfile,
projectionRetryParams?.codeAgentProviderProfile,
projectionRetryParams?.backendProfile,
mapped.agentRun.backendProfile
)
});
recordAgentRunEventsProjectionMetrics(performanceStore, eventsResponse, previousLastSeq, nextLastSeq);
const terminalFromEvents = agentRunTerminalStatusFromEvents(eventsResponse?.events);
await writeWorkbenchProjectionStateForAgentRun(options.runtimeStore, {
@@ -2090,6 +2098,7 @@ function agentRunResultToCodeAgentPayload({ base, result, traceStore, traceId, a
return {
...base,
status: "completed",
messageId: finalResponse?.messageId ?? base.messageId ?? `msg_${traceId.slice(4)}`,
threadId: agentRunEffectiveThreadId(base),
updatedAt: now,
workspace: base.workspace ?? "/home/agentrun/workspace",
@@ -2148,6 +2157,7 @@ function agentRunResultToCodeAgentPayload({ base, result, traceStore, traceId, a
return {
...base,
status: canceled ? "canceled" : "failed",
messageId: finalResponse.messageId,
threadId: agentRunEffectiveThreadId(base),
canceled,
updatedAt: now,