fix: align AgentRun reuse assertions with spec
This commit is contained in:
@@ -448,7 +448,7 @@ export async function syncAgentRunChatResult({ traceId, currentResult = null, op
|
||||
timeoutMs,
|
||||
env
|
||||
});
|
||||
const nextMapping = {
|
||||
const nextMapping = withAgentRunRunnerJobCount({
|
||||
...mapped.agentRun,
|
||||
...agentRunResultRefs(result),
|
||||
lastSeq: eventsResponse ? agentRunTraceCursorSeq(eventsResponse, mapped.agentRun.lastSeq) : mapped.agentRun.lastSeq,
|
||||
@@ -458,7 +458,7 @@ export async function syncAgentRunChatResult({ traceId, currentResult = null, op
|
||||
terminalStatus: result?.terminalStatus ?? mapped.agentRun.terminalStatus ?? null,
|
||||
updatedAt: nowIso(options.now),
|
||||
valuesPrinted: false
|
||||
};
|
||||
});
|
||||
const base = { ...mapped, agentRun: nextMapping, updatedAt: nowIso(options.now) };
|
||||
const payload = agentRunResultToCodeAgentPayload({ base, result, traceStore, traceId, appendResultEvent });
|
||||
options.codeAgentChatResults?.set?.(traceId, payload);
|
||||
@@ -2065,6 +2065,17 @@ function agentRunResultRefs(result = {}) {
|
||||
return refs;
|
||||
}
|
||||
|
||||
function withAgentRunRunnerJobCount(mapping = {}) {
|
||||
if (!mapping || typeof mapping !== "object") return mapping;
|
||||
const count = Number(mapping.runnerJobCount);
|
||||
if (Number.isFinite(count) && count >= 0) return mapping;
|
||||
const runnerJobEnsured = mapping.reused === true || mapping.status === "runner-job-ensured";
|
||||
if (runnerJobEnsured && (mapping.runnerJobId || mapping.jobName || mapping.attemptId || mapping.runnerId)) {
|
||||
return { ...mapping, runnerJobCount: 1 };
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
|
||||
function hwlabSessionIdForParams(params = {}, traceId) {
|
||||
return safeSessionId(params.sessionId) || agentRunSessionId(traceId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user