feat: add orchestrator shadow observability

This commit is contained in:
john
2026-07-24 21:44:21 +08:00
parent 24336d0178
commit 3e57f85d3a
18 changed files with 992 additions and 9 deletions
+5
View File
@@ -342,6 +342,7 @@ export function createAgentRunGateway({
function dispatchShadowObservation(input) {
if (typeof observeWorkflowRun !== 'function' || input.toolMode !== 'code') return;
setImmediate(() => {
const observationStartedAt = nowMs();
void Promise.resolve()
.then(() => observeWorkflowRun(input))
.then(async (result) => {
@@ -352,6 +353,9 @@ export function createAgentRunGateway({
configVersion: result.configVersion ?? null,
status: result.shadowRun?.status ?? null,
phase: result.shadowRun?.phase ?? null,
taskType: result.shadowRun?.plan?.taskType ?? input.taskType ?? null,
executorAdapter: result.shadowRun?.plan?.executorAdapter ?? null,
latencyMs: Math.max(0, nowMs() - observationStartedAt),
});
})
.catch(async (error) => {
@@ -362,6 +366,7 @@ export function createAgentRunGateway({
await appendEvent(input.runId, 'workflow_shadow_failed', {
code: String(error?.code ?? 'WORKFLOW_SHADOW_FAILED').slice(0, 128),
message: String(error instanceof Error ? error.message : error).slice(0, 1000),
latencyMs: Math.max(0, nowMs() - observationStartedAt),
}).catch((appendError) => {
console.warn(
'[AgentRun] workflow shadow failure event skipped:',