fix: backfill AgentRun terminal projection on read
This commit is contained in:
@@ -1589,16 +1589,25 @@ function agentRunLongLivedSessionGate(base = {}) {
|
||||
}
|
||||
|
||||
function agentRunToolCalls(result = {}, status = "completed") {
|
||||
const replyText = agentRunReplyText(result);
|
||||
return [{
|
||||
name: "agentrun.v01.command.turn",
|
||||
status,
|
||||
runId: result?.runId ?? null,
|
||||
commandId: result?.commandId ?? null,
|
||||
outputSummary: result?.reply ? `assistantChars=${String(result.reply).length}` : null,
|
||||
outputSummary: replyText ? `assistantChars=${replyText.length}` : null,
|
||||
valuesPrinted: false
|
||||
}];
|
||||
}
|
||||
|
||||
function agentRunReplyText(result = {}) {
|
||||
for (const value of [result?.reply, result?.assistantMessage, result?.finalResponse, result?.content, result?.text, result?.message]) {
|
||||
const text = promptTextValue(value);
|
||||
if (text) return text;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function agentRunResultToCodeAgentPayload({ base, result, traceStore, traceId, appendResultEvent = true }) {
|
||||
const terminalStatus = String(result?.terminalStatus ?? "");
|
||||
const terminal = terminalStatus === "completed" || terminalStatus === "failed" || terminalStatus === "blocked" || terminalStatus === "cancelled";
|
||||
@@ -1609,8 +1618,9 @@ function agentRunResultToCodeAgentPayload({ base, result, traceStore, traceId, a
|
||||
const runnerTrace = traceStore.snapshot(traceId, agentRunTraceMeta({}, {}));
|
||||
const terminalEventCreatedAt = agentRunResultTraceCreatedAt(runnerTrace, now);
|
||||
const providerTrace = agentRunProviderTrace({ base, result, terminalStatus });
|
||||
if (terminalStatus === "completed" && String(result?.reply ?? "").trim()) {
|
||||
const finalResponse = agentRunCompletedFinalResponse({ base, result, traceId, now });
|
||||
const replyText = agentRunReplyText(result);
|
||||
if (terminalStatus === "completed" && replyText) {
|
||||
const finalResponse = agentRunCompletedFinalResponse({ base, result, traceId, now, replyText });
|
||||
const traceSummary = agentRunCompletedTraceSummary({ base, runnerTrace, finalResponse, traceId });
|
||||
if (appendResultEvent) {
|
||||
traceStore.append(traceId, agentRunTraceEvent({
|
||||
@@ -1724,8 +1734,8 @@ function agentRunResultToCodeAgentPayload({ base, result, traceStore, traceId, a
|
||||
};
|
||||
}
|
||||
|
||||
function agentRunCompletedFinalResponse({ base, result, traceId, now }) {
|
||||
const textValue = String(result?.reply ?? "").trim();
|
||||
function agentRunCompletedFinalResponse({ base, result, traceId, now, replyText = null }) {
|
||||
const textValue = promptTextValue(replyText) || agentRunReplyText(result);
|
||||
return {
|
||||
text: textValue,
|
||||
textChars: textValue.length,
|
||||
|
||||
Reference in New Issue
Block a user