WorkflowSubflowRecord
CORE · type · Type contract
Historical subflow snapshots may omit recorder fields or descriptive content.
Import
ts
import type { WorkflowSubflowRecord } from '@jangts/agent-core/engine';js
/** @typedef {import('@jangts/agent-core/engine').WorkflowSubflowRecord} WorkflowSubflowRecord */Other public entry points:@jangts/agent-core, @jangts/agent-core/engine, @jangts/agent-core/types, @jangts/agent-core/structs.
Definition
Type: WorkflowSubflowRecord
Type expression
ts
type WorkflowSubflowRecord = Omit<RecordedSubStep, 'name' | 'kind'> & {
readonly name?: string;
readonly kind?: string;
readonly sourceEventId?: string;
readonly producerSequence?: number;
};Field structure
| Field | Type | Required | Description |
|---|---|---|---|
subnodeId | string | undefined | Optional | Read-only. Logical subnode grouping within this node visit; independent of individual log ids. |
stepId | string | Required | Read-only. Log record identity, unique within one node visit; not a subnode id. |
type | string | undefined | Optional | Read-only. App-defined business log type; never a write/fix operation enum. |
parentStepId | string | undefined | Optional | Read-only. Reported parent step, forming a tree; absent for a top-level step. |
relatedDefinitionId | string | undefined | Optional | Read-only. Self-reported reference only; never a workflow dispatch identity. |
relatedInvocationId | string | undefined | Optional | Read-only. Real model/tool invocation identity, kept separate from the node-local subnode id. |
status | "error" | "success" | "unknown" | "planned" | "running" | "cancelled" | "skipped" | undefined | Optional | Read-only. Reported lifecycle status; omission means the node did not report one. |
usedModel | boolean | undefined | Optional | Read-only. This step's own reported model use, never a descendant rollup. |
startedAtMs | number | undefined | Optional | Read-only. Reported start instant in epoch milliseconds. |
endedAtMs | number | undefined | Optional | Read-only. Reported end instant in epoch milliseconds; only meaningful for terminal statuses. |
nextStepIds | readonly string[] | undefined | Optional | Read-only. Reported successor step ids, for display only. |
caseId | string | undefined | Optional | Read-only. Reported case or variant id, interpreted by the App. |
summary | string | undefined | Optional | Read-only. Reported one-line summary. |
payload | Readonly<Record<string, SubFlowValue>> | undefined | Optional | Read-only. Reported payload; the recorder snapshots it and bounds the total size. |
createdAtMs | number | undefined | Optional | Read-only. Optional only for historical records produced before the logger contract. |
revision | number | undefined | Optional | Read-only. Revision number, incremented by each accepted fix. |
origin | "reported" | Required | Read-only. Historical marker: only self-reported steps are recorded. |
operation | "write" | "fix" | undefined | Optional | Read-only. Append-only logging operation, separate from the App-owned business type. |
targetStepId | string | undefined | Optional | Read-only. Original write record revised by this fix; fixes have their own stepId. |
sequence | number | Required | Read-only. One-based append order within the node visit, including every fix. |
name | string | undefined | Optional | Read-only. See the type definition and usage context. |
kind | string | undefined | Optional | Read-only. See the type definition and usage context. |
sourceEventId | string | undefined | Optional | Read-only. See the type definition and usage context. |
producerSequence | number | undefined | Optional | Read-only. See the type definition and usage context. |
Examples
- Workflow: nodes, routes, and partial state updates: Use a single node definition that actually participates in execution to show order, branches, error destinations, and end conditions together.
- Reusing a base Workflow and Agent branches: add preserves the old Workflow and produces a new combined Workflow; fork inherits existing bindings and the branch origin.
A single node completes the greeting
Beginner · Node.js
ts
import { AgentCoreEngine, defineWorkflow, route } from '@jangts/agent-core/engine';
type State = { name: string; answer?: string };
const workflow = defineWorkflow<State, string>({
id: 'greeting',
nodes: [{
id: 'greet', description: '根据本次姓名生成问候', startsRound: true,
run: state => ({ answer: '你好,' + state.name }),
routes: [route.deliver('answer')],
}],
});
console.log(workflow.entryNodeId);
console.log(workflow.describe());js
import { AgentCoreEngine, defineWorkflow, route } from '@jangts/agent-core/engine';
const workflow = defineWorkflow({
id: 'greeting',
nodes: [{
id: 'greet', description: '根据本次姓名生成问候', startsRound: true,
run: state => ({ answer: '你好,' + state.name }),
routes: [route.deliver('answer')],
}],
});
console.log(workflow.entryNodeId);
console.log(workflow.describe());Add a validation stage without changing state or the run call
Configuration · Node.js
ts
import { AgentCoreEngine, defineWorkflow, route } from '@jangts/agent-core/engine';
type State = { name: string; answer?: string; error?: string };
const workflow = defineWorkflow<State, string>({
id: 'greeting',
nodes: [
{ id: 'check', description: '检查姓名', startsRound: true,
run: state => ({ error: state.name.trim() ? undefined : '姓名不能为空' }),
routes: [route.toIfError('failure'), route.to('greet')] },
{ id: 'greet', description: '生成问候', provides: ['answer'],
run: state => ({ answer: '你好,' + state.name }), routes: [route.deliver('answer')] },
{ id: 'failure', description: '返回校验提示', requires: ['error'], routes: [route.deliver('error')] },
],
});
console.log(await new AgentCoreEngine({ workflow }).run({ name: 'Ivan' }));js
import { AgentCoreEngine, defineWorkflow, route } from '@jangts/agent-core/engine';
const workflow = defineWorkflow({
id: 'greeting',
nodes: [
{ id: 'check', description: '检查姓名', startsRound: true,
run: state => ({ error: state.name.trim() ? undefined : '姓名不能为空' }),
routes: [route.toIfError('failure'), route.to('greet')] },
{ id: 'greet', description: '生成问候', provides: ['answer'],
run: state => ({ answer: '你好,' + state.name }), routes: [route.deliver('answer')] },
{ id: 'failure', description: '返回校验提示', requires: ['error'], routes: [route.deliver('error')] },
],
});
console.log(await new AgentCoreEngine({ workflow }).run({ name: 'Ivan' }));Related policy source
- Execution implementation of the bounded loop, commit, and cancellation
- Reference, reachability, and bounded-loop validation