fix(workbench): keep running agent timing visible (#1980)
Co-authored-by: root <root@lyon.remote>
This commit is contained in:
@@ -233,8 +233,7 @@ export function initialAgentRunChatResult({ params = {}, options = {}, traceId }
|
||||
sessionId: safeSessionId(params.sessionId) || agentRunSessionId(traceId),
|
||||
threadId: safeOpaqueId(params.threadId) || null,
|
||||
messageId: `msg_${safeTraceId(traceId)?.slice(4) || randomUUID()}`,
|
||||
createdAt: timestamp,
|
||||
updatedAt: timestamp,
|
||||
...agentRunAdmissionTimingFields(timestamp),
|
||||
provider: providerForBackendProfile(backendProfile),
|
||||
model: modelForBackendProfile(backendProfile, env),
|
||||
backend: backendForBackendProfile(backendProfile),
|
||||
@@ -258,6 +257,28 @@ export function initialAgentRunChatResult({ params = {}, options = {}, traceId }
|
||||
};
|
||||
}
|
||||
|
||||
function agentRunAdmissionTimingFields(value) {
|
||||
const admittedAt = timestampIsoOrNow(value);
|
||||
const timing = {
|
||||
startedAt: admittedAt,
|
||||
lastEventAt: admittedAt,
|
||||
finishedAt: null,
|
||||
durationMs: null,
|
||||
observedAt: admittedAt,
|
||||
lastEventAgeMs: 0,
|
||||
valuesRedacted: true
|
||||
};
|
||||
return {
|
||||
createdAt: admittedAt,
|
||||
updatedAt: admittedAt,
|
||||
timing,
|
||||
startedAt: admittedAt,
|
||||
lastEventAt: admittedAt,
|
||||
finishedAt: null,
|
||||
durationMs: null
|
||||
};
|
||||
}
|
||||
|
||||
export async function submitAgentRunChatTurn({ params = {}, options = {}, traceId, traceStore = defaultCodeAgentTraceStore, results }) {
|
||||
const env = options.env ?? process.env;
|
||||
const managerUrl = resolveAgentRunManagerUrl(env);
|
||||
@@ -3222,6 +3243,11 @@ function nowIso(now) {
|
||||
return typeof now === "function" ? now() : new Date().toISOString();
|
||||
}
|
||||
|
||||
function timestampIsoOrNow(value = null) {
|
||||
const parsed = Date.parse(String(value ?? ""));
|
||||
return Number.isFinite(parsed) ? new Date(parsed).toISOString() : new Date().toISOString();
|
||||
}
|
||||
|
||||
function redactUrl(value) {
|
||||
try {
|
||||
const url = new URL(value);
|
||||
|
||||
Reference in New Issue
Block a user