fix: expose run step identities across transports

This commit is contained in:
lda
2026-09-05 23:40:25 +07:00 Verified
parent fd48a67819
commit 0612247f56
13 changed files with 97 additions and 0 deletions
@@ -2481,6 +2481,7 @@ export interface TraceEntryPayload {
output: JsonObject;
resolved_input: JsonObject;
state_changes: JsonObject;
step_number: number | null;
step_type: string;
[k: string]: unknown;
}
@@ -5018,6 +5019,16 @@ export const workflowRuntimeContract = {
"state_changes": {
"$ref": "#/components/schemas/JsonObject"
},
"step_number": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
]
},
"step_type": {
"type": "string"
}
@@ -5026,6 +5037,7 @@ export const workflowRuntimeContract = {
"frame_id",
"node_id",
"step_type",
"step_number",
"resolved_input",
"outcome",
"next_node_id",
@@ -301,11 +301,15 @@ const RunResultSchema = Schema.Struct({
output: Schema.NullOr(JsonObjectSchema),
diagnostics: Schema.Array(Schema.Unknown),
trace_count: NonNegativeIntegerSchema,
max_steps: PositiveIntegerSchema,
steps_executed: NonNegativeIntegerSchema,
steps_remaining: NonNegativeIntegerSchema,
next_actions: RunNextActionsSchema,
});
const TraceFrameSchema = Schema.Struct({
node_id: Schema.String,
step_type: Schema.String,
step_number: Schema.NullOr(PositiveIntegerSchema),
resolved_input: JsonObjectSchema,
outcome: Schema.String,
output: JsonObjectSchema,
@@ -764,6 +768,7 @@ export const authoredRpcSchemas = {
deployment_id: Schema.String,
workflow_input: JsonObjectSchema,
trace_range: Schema.optional(Schema.NullOr(TraceRangeSchema)),
max_steps: Schema.optional(PositiveIntegerSchema),
}),
success: RunResultSchema,
},
@@ -141,6 +141,9 @@ const interruptedRun = {
output: null,
diagnostics: [],
trace_count: 1,
max_steps: 10_000,
steps_executed: 1,
steps_remaining: 9_999,
next_actions: nextActions,
};
@@ -173,11 +176,14 @@ const completedRun = {
outcome: "completed",
output: { report: "# Completed report" },
trace_count: 4,
steps_executed: 4,
steps_remaining: 9_996,
};
const authoredTraceFrame = {
node_id: "review_issues",
step_type: "interrupt",
step_number: 1,
resolved_input: { report: "# Draft report" },
outcome: "submitted",
output: {},
@@ -315,6 +315,9 @@ describe("runtimeSchemasFor", () => {
output: null,
diagnostics: [],
trace_count: 1,
max_steps: 10_000,
steps_executed: 1,
steps_remaining: 9_999,
next_actions: {
can_continue: true,
can_save_now: null,
@@ -381,6 +384,7 @@ describe("runtimeSchemasFor", () => {
frame_id: "frame_1",
node_id: "review_issues",
step_type: "interrupt",
step_number: 1,
resolved_input: {},
outcome: "submitted",
next_node_id: "create_issues",
@@ -401,6 +405,9 @@ describe("runtimeSchemasFor", () => {
output: {},
diagnostics: [],
trace_count: 1,
max_steps: 10_000,
steps_executed: 1,
steps_remaining: 9_999,
next_actions: {
can_continue: false,
can_save_now: null,
@@ -65,6 +65,9 @@ describe("checked workflow manifest translation", () => {
run_id: "run_123",
status: "completed",
trace_count: 9,
max_steps: 10_000,
steps_executed: 9,
steps_remaining: 9_991,
}),
),
).toBe(true);
+7
View File
@@ -389,6 +389,9 @@ const interpretRunDetail = (decoded: {
readonly output: Record<string, unknown> | null;
readonly diagnostics: ReadonlyArray<unknown>;
readonly trace_count: number;
readonly max_steps: number;
readonly steps_executed: number;
readonly steps_remaining: number;
readonly next_actions: Parameters<typeof interpretNextActions>[0];
}) => ({
runId: decoded.run_id,
@@ -403,6 +406,9 @@ const interpretRunDetail = (decoded: {
output: decoded.output,
diagnostics: decoded.diagnostics,
traceCount: decoded.trace_count,
maxSteps: decoded.max_steps,
stepsExecuted: decoded.steps_executed,
stepsRemaining: decoded.steps_remaining,
nextActions: interpretNextActions(decoded.next_actions),
});
@@ -1268,6 +1274,7 @@ const operationEntries = defineOperationEntries([
frameId: entry.frame_id,
nodeId: entry.node_id,
stepType: entry.step_type,
stepNumber: entry.step_number,
outcome: entry.outcome,
nextNodeId: entry.next_node_id,
resolvedInput: entry.resolved_input,
+17
View File
@@ -483,6 +483,9 @@ const lifecycleCases = [
output: null,
diagnostics: [],
trace_count: 0,
max_steps: 10_000,
steps_executed: 1,
steps_remaining: 9_999,
next_actions: {
can_continue: false,
can_save_now: null,
@@ -550,6 +553,9 @@ const lifecycleCases = [
output: null,
diagnostics: [],
trace_count: 1,
max_steps: 10_000,
steps_executed: 1,
steps_remaining: 9_999,
next_actions: {
can_continue: true,
can_save_now: null,
@@ -597,6 +603,9 @@ const lifecycleCases = [
},
diagnostics: [],
trace_count: 4,
max_steps: 10_000,
steps_executed: 4,
steps_remaining: 9_996,
next_actions: {
can_continue: false,
can_save_now: null,
@@ -635,6 +644,9 @@ const lifecycleCases = [
output: null,
diagnostics: [],
trace_count: 1,
max_steps: 10_000,
steps_executed: 1,
steps_remaining: 9_999,
next_actions: {
can_continue: true,
can_save_now: null,
@@ -651,6 +663,7 @@ const lifecycleCases = [
frame_id: "frame_1",
node_id: "review",
step_type: "interrupt",
step_number: 1,
resolved_input: { report: "..." },
outcome: "submitted",
output: {},
@@ -958,6 +971,7 @@ describe("lifecycle operations", () => {
frameId: "frame_1",
nodeId: "review",
stepType: "interrupt",
stepNumber: 1,
outcome: "submitted",
nextNodeId: "create_issues",
},
@@ -1019,6 +1033,9 @@ describe("lifecycle operations", () => {
expect(exchange.interpreted).toMatchObject({
runId: "run_demo",
status: "interrupted",
maxSteps: 10_000,
stepsExecuted: 1,
stepsRemaining: 9_999,
interrupt: {
kind: "issue_review",
typed: true,