feat: add workflow dry-run observability
This commit is contained in:
+26
-20
@@ -339,6 +339,30 @@ export function createAgentRunGateway({
|
||||
);
|
||||
}
|
||||
|
||||
async function appendExecutionPlanEvent(input, source) {
|
||||
const executionPlan = source?.executionPlan;
|
||||
if (!executionPlan?.dryRun) return;
|
||||
await appendEvent(input.runId, 'workflow_execution_planned', {
|
||||
version: executionPlan.version ?? 'workflow-execution-decision-v1',
|
||||
mode: source.mode ?? null,
|
||||
candidateEngine: executionPlan.candidateEngine ?? null,
|
||||
effectiveEngine: executionPlan.effectiveEngine ?? 'native',
|
||||
fallbackEngine: executionPlan.fallbackEngine ?? 'native',
|
||||
reason: executionPlan.reason ?? 'execution_gate_disabled',
|
||||
candidateReason: executionPlan.candidateReason ?? null,
|
||||
configVersion: executionPlan.configVersion ?? null,
|
||||
bucket: executionPlan.bucket ?? null,
|
||||
taskType: executionPlan.taskType ?? input.taskType ?? null,
|
||||
dryRun: true,
|
||||
handoffAllowed: false,
|
||||
}).catch((error) => {
|
||||
console.warn(
|
||||
'[AgentRun] workflow execution plan event skipped:',
|
||||
error instanceof Error ? error.message : error,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function dispatchShadowObservation(input) {
|
||||
if (typeof observeWorkflowRun !== 'function' || input.toolMode !== 'code') return;
|
||||
setImmediate(() => {
|
||||
@@ -346,26 +370,7 @@ export function createAgentRunGateway({
|
||||
void Promise.resolve()
|
||||
.then(() => observeWorkflowRun(input))
|
||||
.then(async (result) => {
|
||||
if (result?.executionPlan?.dryRun) {
|
||||
await appendEvent(input.runId, 'workflow_execution_planned', {
|
||||
version: result.executionPlan.version ?? 'workflow-execution-decision-v1',
|
||||
mode: result.mode ?? null,
|
||||
candidateEngine: result.executionPlan.candidateEngine ?? null,
|
||||
effectiveEngine: result.executionPlan.effectiveEngine ?? 'native',
|
||||
fallbackEngine: result.executionPlan.fallbackEngine ?? 'native',
|
||||
reason: result.executionPlan.reason ?? 'execution_gate_disabled',
|
||||
candidateReason: result.executionPlan.candidateReason ?? null,
|
||||
configVersion: result.executionPlan.configVersion ?? null,
|
||||
bucket: result.executionPlan.bucket ?? null,
|
||||
dryRun: true,
|
||||
handoffAllowed: false,
|
||||
}).catch((error) => {
|
||||
console.warn(
|
||||
'[AgentRun] workflow execution plan event skipped:',
|
||||
error instanceof Error ? error.message : error,
|
||||
);
|
||||
});
|
||||
}
|
||||
await appendExecutionPlanEvent(input, result);
|
||||
if (!result?.observed) return;
|
||||
await appendEvent(input.runId, 'workflow_shadow_completed', {
|
||||
engine: result.engine ?? 'langgraph',
|
||||
@@ -379,6 +384,7 @@ export function createAgentRunGateway({
|
||||
});
|
||||
})
|
||||
.catch(async (error) => {
|
||||
await appendExecutionPlanEvent(input, error);
|
||||
console.warn(
|
||||
'[AgentRun] workflow shadow observation failed:',
|
||||
error instanceof Error ? error.message : error,
|
||||
|
||||
Reference in New Issue
Block a user