feat: add Workbench L0 phase timing

This commit is contained in:
root
2026-07-19 18:32:45 +02:00
parent 7a8df7fead
commit 6ea48d5f2f
2 changed files with 125 additions and 13 deletions
+25 -5
View File
@@ -165,10 +165,10 @@ describe("Workbench native HTTP adapter", () => {
], {});
for (let index = 0; index < 20 && subscribers.size === 0; index += 1) await Bun.sleep(5);
const events = [
{ type: "user", eventType: "user" },
{ type: "backend", eventType: "backend" },
{ type: "assistant", eventType: "assistant", final: true, replyAuthority: true, finalResponse: { text: "done" } },
{ type: "result", eventType: "terminal", terminal: true, terminalStatus: "completed", status: "completed" }
{ type: "user", eventType: "user", createdAt: "2026-07-19T16:00:00.000Z" },
{ type: "backend", eventType: "backend", createdAt: "2026-07-19T16:00:02.000Z" },
{ type: "assistant", eventType: "assistant", createdAt: "2026-07-19T16:01:02.000Z", final: true, replyAuthority: true, finalResponse: { text: "done" } },
{ type: "result", eventType: "terminal", createdAt: "2026-07-19T16:01:03.000Z", terminal: true, terminalStatus: "completed", status: "completed" }
];
for (const event of events) {
for (const listener of subscribers) listener({ schema: "hwlab.event.v1", sessionId: "ses_l0_semantics", traceId: "trc_l0_semantics", event });
@@ -181,7 +181,27 @@ describe("Workbench native HTTP adapter", () => {
observedSemantics: ["user", "backend", "assistant", "terminal", "final"],
missingSemantics: [],
semanticCounts: { user: 1, backend: 1, assistant: 1, terminal: 1, final: 1 },
terminalStatuses: ["completed"]
terminalStatuses: ["completed"],
timing: {
clock: "agentrun-source-event-created-at",
phasesMs: {
firstEventToBackend: 2000,
admissionAndDispatch: null,
runnerProvisioning: null,
runtimePreparation: null,
providerExecution: null,
backendToAssistant: 60000,
assistantToTerminal: 1000,
firstEventToTerminal: 63000,
firstEventToFinal: 62000
},
slowestGap: {
durationMs: 60000,
toIndex: 2,
toEventType: "assistant"
},
valuesPrinted: false
}
});
} finally {
server.stop(true);