Skip to content
中文

ExecutionObserver ​

CORE · interface · Type contract

Live consumer of Core facts.

Import ​

ts
import type { ExecutionObserver } from '@jangts/agent-core';
js
/** @typedef {import('@jangts/agent-core').ExecutionObserver} ExecutionObserver */

Other public entry points:@jangts/agent-core, @jangts/agent-core/types, @jangts/agent-core/structs.

Definition ​

ts
interface ExecutionObserver

Field structure ​

FieldTypeRequiredDescription
accepts((descriptor: Readonly<ExecutionEventDescriptor>) => boolean) | undefinedOptionalMetadata-only by default. Content requires an explicit accepts decision.
event(event: Readonly<CoreEvent>) => void | Promise<void>RequiredHandles one fact; a rejected promise propagates to the emitting call.

Member index ​

MemberPurpose
eventHandles one fact; a rejected promise propagates to the emitting call.

Member details ​

event ​

Handles one fact; a rejected promise propagates to the emitting call.

ts
ExecutionObserver.event(event: Readonly<CoreEvent>): void | Promise<void>

Handles one fact; a rejected promise propagates to the emitting call.

ParameterTypePassingDescription
eventReadonly<CoreEvent>Required—

Optional shapes of Parameter event: choose one shape; required fields for each branch are listed separately.

Branch 1
FieldTypeRequiredDescription
runIdstringRequiredRead-only. Root run id shared by every fact of one logical run.
spanIdstringRequiredRead-only. Span that produced the fact.
parentSpanIdstring | undefinedOptionalRead-only. Enclosing span; absent for a root span.
invocationIdstring | undefinedOptionalRead-only. Invocation that produced the fact, when the fact belongs to one.
parentInvocationIdstring | undefinedOptionalRead-only. Enclosing invocation, when one invocation triggers another.
nodeRole"invocation" | "workflow-node" | "workflow-boundary" | "loop-step" | undefinedOptionalRead-only. Role the emitting span plays in the execution graph.
agentIdstring | undefinedOptionalRead-only. App-owned agent identity.
branchIdstring | undefinedOptionalRead-only. App-owned branch identity.
agentVersionIdstring | undefinedOptionalRead-only. App-owned immutable version identity of the agent definition.
parentBranchIdstring | undefinedOptionalRead-only. Branch this branch was forked from, when applicable.
parentAgentVersionIdstring | undefinedOptionalRead-only. Version of the parent branch at the fork point.
forkPointIdstring | undefinedOptionalRead-only. App-owned fork marker shared by the forked branch and its origin.
workflowInvocationIdstring | undefinedOptionalRead-only. Workflow invocation the fact belongs to.
workflowNodeIdstring | undefinedOptionalRead-only. Workflow node invocation the fact belongs to.
definitionKindstring | undefinedOptionalRead-only. Kind of the workflow/agent definition that dispatched the node.
definitionIdstring | undefinedOptionalRead-only. Id of that definition.
definitionRevisionstring | undefinedOptionalRead-only. Revision of that definition; distinguishes executions of different definition states.
nodeIdstring | undefinedOptionalRead-only. Node id inside the workflow.
nodeNamestring | undefinedOptionalRead-only. Human-readable node name.
nodeKindstring | undefinedOptionalRead-only. Node kind as declared by the App.
nodeDescriptionstring | undefinedOptionalRead-only. Optional node description for diagnostics display.
stageIdstring | undefinedOptionalRead-only. Model stage that produced the fact.
modelIdstring | undefinedOptionalRead-only. Model binding used, when the fact concerns a model call.
version2RequiredEnvelope version; consumers must reject anything else.
eventIdstringRequiredUnique id of this fact, stable across observers and log writers.
type"loop.event"RequiredDiscriminator matching payload.
producerSequencenumberRequiredMonotonic counter owned by the producing scope; starts at 1 for each producer.
occurredAtMsnumberRequiredInstant the fact occurred, in epoch milliseconds.
payloadLoopEventRequiredEvent-specific facts.
usedModelboolean | undefinedOptionalWhether the reported step used a model; omitted when the producer did not state it.
subStepsreadonly RecordedSubStep[]RequiredReported sub-steps attached to this fact, bounded and already validated.
subStepsDroppednumberRequiredNumber of reported sub-steps omitted by the recorder's bounds.
subStepsTruncatedbooleanRequiredTrue when reported sub-steps were truncated, so the attached list is incomplete.
Branch 2
FieldTypeRequiredDescription
runIdstringRequiredRead-only. Root run id shared by every fact of one logical run.
spanIdstringRequiredRead-only. Span that produced the fact.
parentSpanIdstring | undefinedOptionalRead-only. Enclosing span; absent for a root span.
invocationIdstring | undefinedOptionalRead-only. Invocation that produced the fact, when the fact belongs to one.
parentInvocationIdstring | undefinedOptionalRead-only. Enclosing invocation, when one invocation triggers another.
nodeRole"invocation" | "workflow-node" | "workflow-boundary" | "loop-step" | undefinedOptionalRead-only. Role the emitting span plays in the execution graph.
agentIdstring | undefinedOptionalRead-only. App-owned agent identity.
branchIdstring | undefinedOptionalRead-only. App-owned branch identity.
agentVersionIdstring | undefinedOptionalRead-only. App-owned immutable version identity of the agent definition.
parentBranchIdstring | undefinedOptionalRead-only. Branch this branch was forked from, when applicable.
parentAgentVersionIdstring | undefinedOptionalRead-only. Version of the parent branch at the fork point.
forkPointIdstring | undefinedOptionalRead-only. App-owned fork marker shared by the forked branch and its origin.
workflowInvocationIdstring | undefinedOptionalRead-only. Workflow invocation the fact belongs to.
workflowNodeIdstring | undefinedOptionalRead-only. Workflow node invocation the fact belongs to.
definitionKindstring | undefinedOptionalRead-only. Kind of the workflow/agent definition that dispatched the node.
definitionIdstring | undefinedOptionalRead-only. Id of that definition.
definitionRevisionstring | undefinedOptionalRead-only. Revision of that definition; distinguishes executions of different definition states.
nodeIdstring | undefinedOptionalRead-only. Node id inside the workflow.
nodeNamestring | undefinedOptionalRead-only. Human-readable node name.
nodeKindstring | undefinedOptionalRead-only. Node kind as declared by the App.
nodeDescriptionstring | undefinedOptionalRead-only. Optional node description for diagnostics display.
stageIdstring | undefinedOptionalRead-only. Model stage that produced the fact.
modelIdstring | undefinedOptionalRead-only. Model binding used, when the fact concerns a model call.
version2RequiredEnvelope version; consumers must reject anything else.
eventIdstringRequiredUnique id of this fact, stable across observers and log writers.
type"model.binding"RequiredDiscriminator matching payload.
producerSequencenumberRequiredMonotonic counter owned by the producing scope; starts at 1 for each producer.
occurredAtMsnumberRequiredInstant the fact occurred, in epoch milliseconds.
payload{ modelId: string; invocationId: string; status: "running" | "success" | "error" | "cancelled"; phase: "input" | "invoke" | "output"; durationMs?: number; errorCode?: string; }RequiredEvent-specific facts.
usedModelboolean | undefinedOptionalWhether the reported step used a model; omitted when the producer did not state it.
subStepsreadonly RecordedSubStep[]RequiredReported sub-steps attached to this fact, bounded and already validated.
subStepsDroppednumberRequiredNumber of reported sub-steps omitted by the recorder's bounds.
subStepsTruncatedbooleanRequiredTrue when reported sub-steps were truncated, so the attached list is incomplete.
Branch 3
FieldTypeRequiredDescription
runIdstringRequiredRead-only. Root run id shared by every fact of one logical run.
spanIdstringRequiredRead-only. Span that produced the fact.
parentSpanIdstring | undefinedOptionalRead-only. Enclosing span; absent for a root span.
invocationIdstring | undefinedOptionalRead-only. Invocation that produced the fact, when the fact belongs to one.
parentInvocationIdstring | undefinedOptionalRead-only. Enclosing invocation, when one invocation triggers another.
nodeRole"invocation" | "workflow-node" | "workflow-boundary" | "loop-step" | undefinedOptionalRead-only. Role the emitting span plays in the execution graph.
agentIdstring | undefinedOptionalRead-only. App-owned agent identity.
branchIdstring | undefinedOptionalRead-only. App-owned branch identity.
agentVersionIdstring | undefinedOptionalRead-only. App-owned immutable version identity of the agent definition.
parentBranchIdstring | undefinedOptionalRead-only. Branch this branch was forked from, when applicable.
parentAgentVersionIdstring | undefinedOptionalRead-only. Version of the parent branch at the fork point.
forkPointIdstring | undefinedOptionalRead-only. App-owned fork marker shared by the forked branch and its origin.
workflowInvocationIdstring | undefinedOptionalRead-only. Workflow invocation the fact belongs to.
workflowNodeIdstring | undefinedOptionalRead-only. Workflow node invocation the fact belongs to.
definitionKindstring | undefinedOptionalRead-only. Kind of the workflow/agent definition that dispatched the node.
definitionIdstring | undefinedOptionalRead-only. Id of that definition.
definitionRevisionstring | undefinedOptionalRead-only. Revision of that definition; distinguishes executions of different definition states.
nodeIdstring | undefinedOptionalRead-only. Node id inside the workflow.
nodeNamestring | undefinedOptionalRead-only. Human-readable node name.
nodeKindstring | undefinedOptionalRead-only. Node kind as declared by the App.
nodeDescriptionstring | undefinedOptionalRead-only. Optional node description for diagnostics display.
stageIdstring | undefinedOptionalRead-only. Model stage that produced the fact.
modelIdstring | undefinedOptionalRead-only. Model binding used, when the fact concerns a model call.
version2RequiredEnvelope version; consumers must reject anything else.
eventIdstringRequiredUnique id of this fact, stable across observers and log writers.
type"model.prepare"RequiredDiscriminator matching payload.
producerSequencenumberRequiredMonotonic counter owned by the producing scope; starts at 1 for each producer.
occurredAtMsnumberRequiredInstant the fact occurred, in epoch milliseconds.
payload{ stageId: string; transportId: string; messages: readonly ModelMessage[]; options: unknown; context?: unknown; }RequiredEvent-specific facts.
usedModelboolean | undefinedOptionalWhether the reported step used a model; omitted when the producer did not state it.
subStepsreadonly RecordedSubStep[]RequiredReported sub-steps attached to this fact, bounded and already validated.
subStepsDroppednumberRequiredNumber of reported sub-steps omitted by the recorder's bounds.
subStepsTruncatedbooleanRequiredTrue when reported sub-steps were truncated, so the attached list is incomplete.
Branch 4
FieldTypeRequiredDescription
runIdstringRequiredRead-only. Root run id shared by every fact of one logical run.
spanIdstringRequiredRead-only. Span that produced the fact.
parentSpanIdstring | undefinedOptionalRead-only. Enclosing span; absent for a root span.
invocationIdstring | undefinedOptionalRead-only. Invocation that produced the fact, when the fact belongs to one.
parentInvocationIdstring | undefinedOptionalRead-only. Enclosing invocation, when one invocation triggers another.
nodeRole"invocation" | "workflow-node" | "workflow-boundary" | "loop-step" | undefinedOptionalRead-only. Role the emitting span plays in the execution graph.
agentIdstring | undefinedOptionalRead-only. App-owned agent identity.
branchIdstring | undefinedOptionalRead-only. App-owned branch identity.
agentVersionIdstring | undefinedOptionalRead-only. App-owned immutable version identity of the agent definition.
parentBranchIdstring | undefinedOptionalRead-only. Branch this branch was forked from, when applicable.
parentAgentVersionIdstring | undefinedOptionalRead-only. Version of the parent branch at the fork point.
forkPointIdstring | undefinedOptionalRead-only. App-owned fork marker shared by the forked branch and its origin.
workflowInvocationIdstring | undefinedOptionalRead-only. Workflow invocation the fact belongs to.
workflowNodeIdstring | undefinedOptionalRead-only. Workflow node invocation the fact belongs to.
definitionKindstring | undefinedOptionalRead-only. Kind of the workflow/agent definition that dispatched the node.
definitionIdstring | undefinedOptionalRead-only. Id of that definition.
definitionRevisionstring | undefinedOptionalRead-only. Revision of that definition; distinguishes executions of different definition states.
nodeIdstring | undefinedOptionalRead-only. Node id inside the workflow.
nodeNamestring | undefinedOptionalRead-only. Human-readable node name.
nodeKindstring | undefinedOptionalRead-only. Node kind as declared by the App.
nodeDescriptionstring | undefinedOptionalRead-only. Optional node description for diagnostics display.
stageIdstring | undefinedOptionalRead-only. Model stage that produced the fact.
modelIdstring | undefinedOptionalRead-only. Model binding used, when the fact concerns a model call.
version2RequiredEnvelope version; consumers must reject anything else.
eventIdstringRequiredUnique id of this fact, stable across observers and log writers.
type"model.output"RequiredDiscriminator matching payload.
producerSequencenumberRequiredMonotonic counter owned by the producing scope; starts at 1 for each producer.
occurredAtMsnumberRequiredInstant the fact occurred, in epoch milliseconds.
payload{ stageId: string; callSequence: number; partIndex: number; part: import("./model/messages.js").ModelPart; }RequiredEvent-specific facts.
usedModelboolean | undefinedOptionalWhether the reported step used a model; omitted when the producer did not state it.
subStepsreadonly RecordedSubStep[]RequiredReported sub-steps attached to this fact, bounded and already validated.
subStepsDroppednumberRequiredNumber of reported sub-steps omitted by the recorder's bounds.
subStepsTruncatedbooleanRequiredTrue when reported sub-steps were truncated, so the attached list is incomplete.
Branch 5
FieldTypeRequiredDescription
runIdstringRequiredRead-only. Root run id shared by every fact of one logical run.
spanIdstringRequiredRead-only. Span that produced the fact.
parentSpanIdstring | undefinedOptionalRead-only. Enclosing span; absent for a root span.
invocationIdstring | undefinedOptionalRead-only. Invocation that produced the fact, when the fact belongs to one.
parentInvocationIdstring | undefinedOptionalRead-only. Enclosing invocation, when one invocation triggers another.
nodeRole"invocation" | "workflow-node" | "workflow-boundary" | "loop-step" | undefinedOptionalRead-only. Role the emitting span plays in the execution graph.
agentIdstring | undefinedOptionalRead-only. App-owned agent identity.
branchIdstring | undefinedOptionalRead-only. App-owned branch identity.
agentVersionIdstring | undefinedOptionalRead-only. App-owned immutable version identity of the agent definition.
parentBranchIdstring | undefinedOptionalRead-only. Branch this branch was forked from, when applicable.
parentAgentVersionIdstring | undefinedOptionalRead-only. Version of the parent branch at the fork point.
forkPointIdstring | undefinedOptionalRead-only. App-owned fork marker shared by the forked branch and its origin.
workflowInvocationIdstring | undefinedOptionalRead-only. Workflow invocation the fact belongs to.
workflowNodeIdstring | undefinedOptionalRead-only. Workflow node invocation the fact belongs to.
definitionKindstring | undefinedOptionalRead-only. Kind of the workflow/agent definition that dispatched the node.
definitionIdstring | undefinedOptionalRead-only. Id of that definition.
definitionRevisionstring | undefinedOptionalRead-only. Revision of that definition; distinguishes executions of different definition states.
nodeIdstring | undefinedOptionalRead-only. Node id inside the workflow.
nodeNamestring | undefinedOptionalRead-only. Human-readable node name.
nodeKindstring | undefinedOptionalRead-only. Node kind as declared by the App.
nodeDescriptionstring | undefinedOptionalRead-only. Optional node description for diagnostics display.
stageIdstring | undefinedOptionalRead-only. Model stage that produced the fact.
modelIdstring | undefinedOptionalRead-only. Model binding used, when the fact concerns a model call.
version2RequiredEnvelope version; consumers must reject anything else.
eventIdstringRequiredUnique id of this fact, stable across observers and log writers.
type"model.parsed"RequiredDiscriminator matching payload.
producerSequencenumberRequiredMonotonic counter owned by the producing scope; starts at 1 for each producer.
occurredAtMsnumberRequiredInstant the fact occurred, in epoch milliseconds.
payload{ stageId: string; callSequence: number; value?: unknown; }RequiredEvent-specific facts.
usedModelboolean | undefinedOptionalWhether the reported step used a model; omitted when the producer did not state it.
subStepsreadonly RecordedSubStep[]RequiredReported sub-steps attached to this fact, bounded and already validated.
subStepsDroppednumberRequiredNumber of reported sub-steps omitted by the recorder's bounds.
subStepsTruncatedbooleanRequiredTrue when reported sub-steps were truncated, so the attached list is incomplete.
Branch 6
FieldTypeRequiredDescription
runIdstringRequiredRead-only. Root run id shared by every fact of one logical run.
spanIdstringRequiredRead-only. Span that produced the fact.
parentSpanIdstring | undefinedOptionalRead-only. Enclosing span; absent for a root span.
invocationIdstring | undefinedOptionalRead-only. Invocation that produced the fact, when the fact belongs to one.
parentInvocationIdstring | undefinedOptionalRead-only. Enclosing invocation, when one invocation triggers another.
nodeRole"invocation" | "workflow-node" | "workflow-boundary" | "loop-step" | undefinedOptionalRead-only. Role the emitting span plays in the execution graph.
agentIdstring | undefinedOptionalRead-only. App-owned agent identity.
branchIdstring | undefinedOptionalRead-only. App-owned branch identity.
agentVersionIdstring | undefinedOptionalRead-only. App-owned immutable version identity of the agent definition.
parentBranchIdstring | undefinedOptionalRead-only. Branch this branch was forked from, when applicable.
parentAgentVersionIdstring | undefinedOptionalRead-only. Version of the parent branch at the fork point.
forkPointIdstring | undefinedOptionalRead-only. App-owned fork marker shared by the forked branch and its origin.
workflowInvocationIdstring | undefinedOptionalRead-only. Workflow invocation the fact belongs to.
workflowNodeIdstring | undefinedOptionalRead-only. Workflow node invocation the fact belongs to.
definitionKindstring | undefinedOptionalRead-only. Kind of the workflow/agent definition that dispatched the node.
definitionIdstring | undefinedOptionalRead-only. Id of that definition.
definitionRevisionstring | undefinedOptionalRead-only. Revision of that definition; distinguishes executions of different definition states.
nodeIdstring | undefinedOptionalRead-only. Node id inside the workflow.
nodeNamestring | undefinedOptionalRead-only. Human-readable node name.
nodeKindstring | undefinedOptionalRead-only. Node kind as declared by the App.
nodeDescriptionstring | undefinedOptionalRead-only. Optional node description for diagnostics display.
stageIdstring | undefinedOptionalRead-only. Model stage that produced the fact.
modelIdstring | undefinedOptionalRead-only. Model binding used, when the fact concerns a model call.
version2RequiredEnvelope version; consumers must reject anything else.
eventIdstringRequiredUnique id of this fact, stable across observers and log writers.
type"model.end"RequiredDiscriminator matching payload.
producerSequencenumberRequiredMonotonic counter owned by the producing scope; starts at 1 for each producer.
occurredAtMsnumberRequiredInstant the fact occurred, in epoch milliseconds.
payload{ stageId: string; state: Readonly<ModelCallTrace>; error?: unknown; receivedParts: number; }RequiredEvent-specific facts.
usedModelboolean | undefinedOptionalWhether the reported step used a model; omitted when the producer did not state it.
subStepsreadonly RecordedSubStep[]RequiredReported sub-steps attached to this fact, bounded and already validated.
subStepsDroppednumberRequiredNumber of reported sub-steps omitted by the recorder's bounds.
subStepsTruncatedbooleanRequiredTrue when reported sub-steps were truncated, so the attached list is incomplete.
Branch 7
FieldTypeRequiredDescription
runIdstringRequiredRead-only. Root run id shared by every fact of one logical run.
spanIdstringRequiredRead-only. Span that produced the fact.
parentSpanIdstring | undefinedOptionalRead-only. Enclosing span; absent for a root span.
invocationIdstring | undefinedOptionalRead-only. Invocation that produced the fact, when the fact belongs to one.
parentInvocationIdstring | undefinedOptionalRead-only. Enclosing invocation, when one invocation triggers another.
nodeRole"invocation" | "workflow-node" | "workflow-boundary" | "loop-step" | undefinedOptionalRead-only. Role the emitting span plays in the execution graph.
agentIdstring | undefinedOptionalRead-only. App-owned agent identity.
branchIdstring | undefinedOptionalRead-only. App-owned branch identity.
agentVersionIdstring | undefinedOptionalRead-only. App-owned immutable version identity of the agent definition.
parentBranchIdstring | undefinedOptionalRead-only. Branch this branch was forked from, when applicable.
parentAgentVersionIdstring | undefinedOptionalRead-only. Version of the parent branch at the fork point.
forkPointIdstring | undefinedOptionalRead-only. App-owned fork marker shared by the forked branch and its origin.
workflowInvocationIdstring | undefinedOptionalRead-only. Workflow invocation the fact belongs to.
workflowNodeIdstring | undefinedOptionalRead-only. Workflow node invocation the fact belongs to.
definitionKindstring | undefinedOptionalRead-only. Kind of the workflow/agent definition that dispatched the node.
definitionIdstring | undefinedOptionalRead-only. Id of that definition.
definitionRevisionstring | undefinedOptionalRead-only. Revision of that definition; distinguishes executions of different definition states.
nodeIdstring | undefinedOptionalRead-only. Node id inside the workflow.
nodeNamestring | undefinedOptionalRead-only. Human-readable node name.
nodeKindstring | undefinedOptionalRead-only. Node kind as declared by the App.
nodeDescriptionstring | undefinedOptionalRead-only. Optional node description for diagnostics display.
stageIdstring | undefinedOptionalRead-only. Model stage that produced the fact.
modelIdstring | undefinedOptionalRead-only. Model binding used, when the fact concerns a model call.
version2RequiredEnvelope version; consumers must reject anything else.
eventIdstringRequiredUnique id of this fact, stable across observers and log writers.
type"runtime.rejected"RequiredDiscriminator matching payload.
producerSequencenumberRequiredMonotonic counter owned by the producing scope; starts at 1 for each producer.
occurredAtMsnumberRequiredInstant the fact occurred, in epoch milliseconds.
payload{ stageId?: string; error: unknown; }RequiredEvent-specific facts.
usedModelboolean | undefinedOptionalWhether the reported step used a model; omitted when the producer did not state it.
subStepsreadonly RecordedSubStep[]RequiredReported sub-steps attached to this fact, bounded and already validated.
subStepsDroppednumberRequiredNumber of reported sub-steps omitted by the recorder's bounds.
subStepsTruncatedbooleanRequiredTrue when reported sub-steps were truncated, so the attached list is incomplete.
Branch 8
FieldTypeRequiredDescription
runIdstringRequiredRead-only. Root run id shared by every fact of one logical run.
spanIdstringRequiredRead-only. Span that produced the fact.
parentSpanIdstring | undefinedOptionalRead-only. Enclosing span; absent for a root span.
invocationIdstring | undefinedOptionalRead-only. Invocation that produced the fact, when the fact belongs to one.
parentInvocationIdstring | undefinedOptionalRead-only. Enclosing invocation, when one invocation triggers another.
nodeRole"invocation" | "workflow-node" | "workflow-boundary" | "loop-step" | undefinedOptionalRead-only. Role the emitting span plays in the execution graph.
agentIdstring | undefinedOptionalRead-only. App-owned agent identity.
branchIdstring | undefinedOptionalRead-only. App-owned branch identity.
agentVersionIdstring | undefinedOptionalRead-only. App-owned immutable version identity of the agent definition.
parentBranchIdstring | undefinedOptionalRead-only. Branch this branch was forked from, when applicable.
parentAgentVersionIdstring | undefinedOptionalRead-only. Version of the parent branch at the fork point.
forkPointIdstring | undefinedOptionalRead-only. App-owned fork marker shared by the forked branch and its origin.
workflowInvocationIdstring | undefinedOptionalRead-only. Workflow invocation the fact belongs to.
workflowNodeIdstring | undefinedOptionalRead-only. Workflow node invocation the fact belongs to.
definitionKindstring | undefinedOptionalRead-only. Kind of the workflow/agent definition that dispatched the node.
definitionIdstring | undefinedOptionalRead-only. Id of that definition.
definitionRevisionstring | undefinedOptionalRead-only. Revision of that definition; distinguishes executions of different definition states.
nodeIdstring | undefinedOptionalRead-only. Node id inside the workflow.
nodeNamestring | undefinedOptionalRead-only. Human-readable node name.
nodeKindstring | undefinedOptionalRead-only. Node kind as declared by the App.
nodeDescriptionstring | undefinedOptionalRead-only. Optional node description for diagnostics display.
stageIdstring | undefinedOptionalRead-only. Model stage that produced the fact.
modelIdstring | undefinedOptionalRead-only. Model binding used, when the fact concerns a model call.
version2RequiredEnvelope version; consumers must reject anything else.
eventIdstringRequiredUnique id of this fact, stable across observers and log writers.
type"node.progress"RequiredDiscriminator matching payload.
producerSequencenumberRequiredMonotonic counter owned by the producing scope; starts at 1 for each producer.
occurredAtMsnumberRequiredInstant the fact occurred, in epoch milliseconds.
payload{ payload?: unknown; subStep?: import("./debug.js").SubStepProgress; reportError?: "INVALID_NODE_REPORT"; }RequiredEvent-specific facts.
usedModelboolean | undefinedOptionalWhether the reported step used a model; omitted when the producer did not state it.
subStepsreadonly RecordedSubStep[]RequiredReported sub-steps attached to this fact, bounded and already validated.
subStepsDroppednumberRequiredNumber of reported sub-steps omitted by the recorder's bounds.
subStepsTruncatedbooleanRequiredTrue when reported sub-steps were truncated, so the attached list is incomplete.
Branch 9
FieldTypeRequiredDescription
runIdstringRequiredRead-only. Root run id shared by every fact of one logical run.
spanIdstringRequiredRead-only. Span that produced the fact.
parentSpanIdstring | undefinedOptionalRead-only. Enclosing span; absent for a root span.
invocationIdstring | undefinedOptionalRead-only. Invocation that produced the fact, when the fact belongs to one.
parentInvocationIdstring | undefinedOptionalRead-only. Enclosing invocation, when one invocation triggers another.
nodeRole"invocation" | "workflow-node" | "workflow-boundary" | "loop-step" | undefinedOptionalRead-only. Role the emitting span plays in the execution graph.
agentIdstring | undefinedOptionalRead-only. App-owned agent identity.
branchIdstring | undefinedOptionalRead-only. App-owned branch identity.
agentVersionIdstring | undefinedOptionalRead-only. App-owned immutable version identity of the agent definition.
parentBranchIdstring | undefinedOptionalRead-only. Branch this branch was forked from, when applicable.
parentAgentVersionIdstring | undefinedOptionalRead-only. Version of the parent branch at the fork point.
forkPointIdstring | undefinedOptionalRead-only. App-owned fork marker shared by the forked branch and its origin.
workflowInvocationIdstring | undefinedOptionalRead-only. Workflow invocation the fact belongs to.
workflowNodeIdstring | undefinedOptionalRead-only. Workflow node invocation the fact belongs to.
definitionKindstring | undefinedOptionalRead-only. Kind of the workflow/agent definition that dispatched the node.
definitionIdstring | undefinedOptionalRead-only. Id of that definition.
definitionRevisionstring | undefinedOptionalRead-only. Revision of that definition; distinguishes executions of different definition states.
nodeIdstring | undefinedOptionalRead-only. Node id inside the workflow.
nodeNamestring | undefinedOptionalRead-only. Human-readable node name.
nodeKindstring | undefinedOptionalRead-only. Node kind as declared by the App.
nodeDescriptionstring | undefinedOptionalRead-only. Optional node description for diagnostics display.
stageIdstring | undefinedOptionalRead-only. Model stage that produced the fact.
modelIdstring | undefinedOptionalRead-only. Model binding used, when the fact concerns a model call.
version2RequiredEnvelope version; consumers must reject anything else.
eventIdstringRequiredUnique id of this fact, stable across observers and log writers.
type"model.start"RequiredDiscriminator matching payload.
producerSequencenumberRequiredMonotonic counter owned by the producing scope; starts at 1 for each producer.
occurredAtMsnumberRequiredInstant the fact occurred, in epoch milliseconds.
payload{ stageId: string; callSequence: number; transportId: string; }RequiredEvent-specific facts.
usedModelboolean | undefinedOptionalWhether the reported step used a model; omitted when the producer did not state it.
subStepsreadonly RecordedSubStep[]RequiredReported sub-steps attached to this fact, bounded and already validated.
subStepsDroppednumberRequiredNumber of reported sub-steps omitted by the recorder's bounds.
subStepsTruncatedbooleanRequiredTrue when reported sub-steps were truncated, so the attached list is incomplete.
Branch 10
FieldTypeRequiredDescription
runIdstringRequiredRead-only. Root run id shared by every fact of one logical run.
spanIdstringRequiredRead-only. Span that produced the fact.
parentSpanIdstring | undefinedOptionalRead-only. Enclosing span; absent for a root span.
invocationIdstring | undefinedOptionalRead-only. Invocation that produced the fact, when the fact belongs to one.
parentInvocationIdstring | undefinedOptionalRead-only. Enclosing invocation, when one invocation triggers another.
nodeRole"invocation" | "workflow-node" | "workflow-boundary" | "loop-step" | undefinedOptionalRead-only. Role the emitting span plays in the execution graph.
agentIdstring | undefinedOptionalRead-only. App-owned agent identity.
branchIdstring | undefinedOptionalRead-only. App-owned branch identity.
agentVersionIdstring | undefinedOptionalRead-only. App-owned immutable version identity of the agent definition.
parentBranchIdstring | undefinedOptionalRead-only. Branch this branch was forked from, when applicable.
parentAgentVersionIdstring | undefinedOptionalRead-only. Version of the parent branch at the fork point.
forkPointIdstring | undefinedOptionalRead-only. App-owned fork marker shared by the forked branch and its origin.
workflowInvocationIdstring | undefinedOptionalRead-only. Workflow invocation the fact belongs to.
workflowNodeIdstring | undefinedOptionalRead-only. Workflow node invocation the fact belongs to.
definitionKindstring | undefinedOptionalRead-only. Kind of the workflow/agent definition that dispatched the node.
definitionIdstring | undefinedOptionalRead-only. Id of that definition.
definitionRevisionstring | undefinedOptionalRead-only. Revision of that definition; distinguishes executions of different definition states.
nodeIdstring | undefinedOptionalRead-only. Node id inside the workflow.
nodeNamestring | undefinedOptionalRead-only. Human-readable node name.
nodeKindstring | undefinedOptionalRead-only. Node kind as declared by the App.
nodeDescriptionstring | undefinedOptionalRead-only. Optional node description for diagnostics display.
stageIdstring | undefinedOptionalRead-only. Model stage that produced the fact.
modelIdstring | undefinedOptionalRead-only. Model binding used, when the fact concerns a model call.
version2RequiredEnvelope version; consumers must reject anything else.
eventIdstringRequiredUnique id of this fact, stable across observers and log writers.
type"workflow.event"RequiredDiscriminator matching payload.
producerSequencenumberRequiredMonotonic counter owned by the producing scope; starts at 1 for each producer.
occurredAtMsnumberRequiredInstant the fact occurred, in epoch milliseconds.
payload{ event: WorkflowEvent; payload?: unknown; }RequiredEvent-specific facts.
usedModelboolean | undefinedOptionalWhether the reported step used a model; omitted when the producer did not state it.
subStepsreadonly RecordedSubStep[]RequiredReported sub-steps attached to this fact, bounded and already validated.
subStepsDroppednumberRequiredNumber of reported sub-steps omitted by the recorder's bounds.
subStepsTruncatedbooleanRequiredTrue when reported sub-steps were truncated, so the attached list is incomplete.
Branch 11
FieldTypeRequiredDescription
runIdstringRequiredRead-only. Root run id shared by every fact of one logical run.
spanIdstringRequiredRead-only. Span that produced the fact.
parentSpanIdstring | undefinedOptionalRead-only. Enclosing span; absent for a root span.
invocationIdstring | undefinedOptionalRead-only. Invocation that produced the fact, when the fact belongs to one.
parentInvocationIdstring | undefinedOptionalRead-only. Enclosing invocation, when one invocation triggers another.
nodeRole"invocation" | "workflow-node" | "workflow-boundary" | "loop-step" | undefinedOptionalRead-only. Role the emitting span plays in the execution graph.
agentIdstring | undefinedOptionalRead-only. App-owned agent identity.
branchIdstring | undefinedOptionalRead-only. App-owned branch identity.
agentVersionIdstring | undefinedOptionalRead-only. App-owned immutable version identity of the agent definition.
parentBranchIdstring | undefinedOptionalRead-only. Branch this branch was forked from, when applicable.
parentAgentVersionIdstring | undefinedOptionalRead-only. Version of the parent branch at the fork point.
forkPointIdstring | undefinedOptionalRead-only. App-owned fork marker shared by the forked branch and its origin.
workflowInvocationIdstring | undefinedOptionalRead-only. Workflow invocation the fact belongs to.
workflowNodeIdstring | undefinedOptionalRead-only. Workflow node invocation the fact belongs to.
definitionKindstring | undefinedOptionalRead-only. Kind of the workflow/agent definition that dispatched the node.
definitionIdstring | undefinedOptionalRead-only. Id of that definition.
definitionRevisionstring | undefinedOptionalRead-only. Revision of that definition; distinguishes executions of different definition states.
nodeIdstring | undefinedOptionalRead-only. Node id inside the workflow.
nodeNamestring | undefinedOptionalRead-only. Human-readable node name.
nodeKindstring | undefinedOptionalRead-only. Node kind as declared by the App.
nodeDescriptionstring | undefinedOptionalRead-only. Optional node description for diagnostics display.
stageIdstring | undefinedOptionalRead-only. Model stage that produced the fact.
modelIdstring | undefinedOptionalRead-only. Model binding used, when the fact concerns a model call.
version2RequiredEnvelope version; consumers must reject anything else.
eventIdstringRequiredUnique id of this fact, stable across observers and log writers.
type"tool.call"RequiredDiscriminator matching payload.
producerSequencenumberRequiredMonotonic counter owned by the producing scope; starts at 1 for each producer.
occurredAtMsnumberRequiredInstant the fact occurred, in epoch milliseconds.
payload{ toolId: string; invocationId: string; input?: unknown; }RequiredEvent-specific facts.
usedModelboolean | undefinedOptionalWhether the reported step used a model; omitted when the producer did not state it.
subStepsreadonly RecordedSubStep[]RequiredReported sub-steps attached to this fact, bounded and already validated.
subStepsDroppednumberRequiredNumber of reported sub-steps omitted by the recorder's bounds.
subStepsTruncatedbooleanRequiredTrue when reported sub-steps were truncated, so the attached list is incomplete.
Branch 12
FieldTypeRequiredDescription
runIdstringRequiredRead-only. Root run id shared by every fact of one logical run.
spanIdstringRequiredRead-only. Span that produced the fact.
parentSpanIdstring | undefinedOptionalRead-only. Enclosing span; absent for a root span.
invocationIdstring | undefinedOptionalRead-only. Invocation that produced the fact, when the fact belongs to one.
parentInvocationIdstring | undefinedOptionalRead-only. Enclosing invocation, when one invocation triggers another.
nodeRole"invocation" | "workflow-node" | "workflow-boundary" | "loop-step" | undefinedOptionalRead-only. Role the emitting span plays in the execution graph.
agentIdstring | undefinedOptionalRead-only. App-owned agent identity.
branchIdstring | undefinedOptionalRead-only. App-owned branch identity.
agentVersionIdstring | undefinedOptionalRead-only. App-owned immutable version identity of the agent definition.
parentBranchIdstring | undefinedOptionalRead-only. Branch this branch was forked from, when applicable.
parentAgentVersionIdstring | undefinedOptionalRead-only. Version of the parent branch at the fork point.
forkPointIdstring | undefinedOptionalRead-only. App-owned fork marker shared by the forked branch and its origin.
workflowInvocationIdstring | undefinedOptionalRead-only. Workflow invocation the fact belongs to.
workflowNodeIdstring | undefinedOptionalRead-only. Workflow node invocation the fact belongs to.
definitionKindstring | undefinedOptionalRead-only. Kind of the workflow/agent definition that dispatched the node.
definitionIdstring | undefinedOptionalRead-only. Id of that definition.
definitionRevisionstring | undefinedOptionalRead-only. Revision of that definition; distinguishes executions of different definition states.
nodeIdstring | undefinedOptionalRead-only. Node id inside the workflow.
nodeNamestring | undefinedOptionalRead-only. Human-readable node name.
nodeKindstring | undefinedOptionalRead-only. Node kind as declared by the App.
nodeDescriptionstring | undefinedOptionalRead-only. Optional node description for diagnostics display.
stageIdstring | undefinedOptionalRead-only. Model stage that produced the fact.
modelIdstring | undefinedOptionalRead-only. Model binding used, when the fact concerns a model call.
version2RequiredEnvelope version; consumers must reject anything else.
eventIdstringRequiredUnique id of this fact, stable across observers and log writers.
type"tool.result"RequiredDiscriminator matching payload.
producerSequencenumberRequiredMonotonic counter owned by the producing scope; starts at 1 for each producer.
occurredAtMsnumberRequiredInstant the fact occurred, in epoch milliseconds.
payload{ toolId: string; invocationId: string; value?: unknown; error?: unknown; errorCode?: string; status: import("./common.js").InvocationStatus; durationMs: number; }RequiredEvent-specific facts.
usedModelboolean | undefinedOptionalWhether the reported step used a model; omitted when the producer did not state it.
subStepsreadonly RecordedSubStep[]RequiredReported sub-steps attached to this fact, bounded and already validated.
subStepsDroppednumberRequiredNumber of reported sub-steps omitted by the recorder's bounds.
subStepsTruncatedbooleanRequiredTrue when reported sub-steps were truncated, so the attached list is incomplete.
Branch 13
FieldTypeRequiredDescription
runIdstringRequiredRead-only. Root run id shared by every fact of one logical run.
spanIdstringRequiredRead-only. Span that produced the fact.
parentSpanIdstring | undefinedOptionalRead-only. Enclosing span; absent for a root span.
invocationIdstring | undefinedOptionalRead-only. Invocation that produced the fact, when the fact belongs to one.
parentInvocationIdstring | undefinedOptionalRead-only. Enclosing invocation, when one invocation triggers another.
nodeRole"invocation" | "workflow-node" | "workflow-boundary" | "loop-step" | undefinedOptionalRead-only. Role the emitting span plays in the execution graph.
agentIdstring | undefinedOptionalRead-only. App-owned agent identity.
branchIdstring | undefinedOptionalRead-only. App-owned branch identity.
agentVersionIdstring | undefinedOptionalRead-only. App-owned immutable version identity of the agent definition.
parentBranchIdstring | undefinedOptionalRead-only. Branch this branch was forked from, when applicable.
parentAgentVersionIdstring | undefinedOptionalRead-only. Version of the parent branch at the fork point.
forkPointIdstring | undefinedOptionalRead-only. App-owned fork marker shared by the forked branch and its origin.
workflowInvocationIdstring | undefinedOptionalRead-only. Workflow invocation the fact belongs to.
workflowNodeIdstring | undefinedOptionalRead-only. Workflow node invocation the fact belongs to.
definitionKindstring | undefinedOptionalRead-only. Kind of the workflow/agent definition that dispatched the node.
definitionIdstring | undefinedOptionalRead-only. Id of that definition.
definitionRevisionstring | undefinedOptionalRead-only. Revision of that definition; distinguishes executions of different definition states.
nodeIdstring | undefinedOptionalRead-only. Node id inside the workflow.
nodeNamestring | undefinedOptionalRead-only. Human-readable node name.
nodeKindstring | undefinedOptionalRead-only. Node kind as declared by the App.
nodeDescriptionstring | undefinedOptionalRead-only. Optional node description for diagnostics display.
stageIdstring | undefinedOptionalRead-only. Model stage that produced the fact.
modelIdstring | undefinedOptionalRead-only. Model binding used, when the fact concerns a model call.
version2RequiredEnvelope version; consumers must reject anything else.
eventIdstringRequiredUnique id of this fact, stable across observers and log writers.
type"rule.result"RequiredDiscriminator matching payload.
producerSequencenumberRequiredMonotonic counter owned by the producing scope; starts at 1 for each producer.
occurredAtMsnumberRequiredInstant the fact occurred, in epoch milliseconds.
payload{ tags: readonly string[]; error: unknown; }RequiredEvent-specific facts.
usedModelboolean | undefinedOptionalWhether the reported step used a model; omitted when the producer did not state it.
subStepsreadonly RecordedSubStep[]RequiredReported sub-steps attached to this fact, bounded and already validated.
subStepsDroppednumberRequiredNumber of reported sub-steps omitted by the recorder's bounds.
subStepsTruncatedbooleanRequiredTrue when reported sub-steps were truncated, so the attached list is incomplete.

Returns: void \| Promise<void>.

Awaited value: void.

Examples ​

  • Process observation and node reports: The App subscribes to Core execution facts; nodes report their own usedModel and use an instance sub-logger to record intent first and then results, while the Loop owns identity and logging.

Observe the nodes and model events a task passes through ​

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')],
  }],
});
const agent = new AgentCoreEngine({ workflow, execution: {
  observe: { event(event) { console.log(event.type, event.eventId); } },
} });
console.log(await agent.run({ name: 'Ivan' }));
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')],
        }],
});
const agent = new AgentCoreEngine({ workflow, execution: {
        observe: { event(event) { console.log(event.type, event.eventId); } },
    } });
console.log(await agent.run({ name: 'Ivan' }));

Report a business stage while the node executes ​

Configuration · Node.js

The node only reports facts it knows; Core owns node identity and execution association.

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, context) {
    context.report({ payload: { phase: 'formatting' } });
    return { answer: '你好,' + state.name };
  }, routes: [route.deliver('answer')],
}] });
const agent = new AgentCoreEngine({ workflow, execution: {
  observe: { event(event) { console.log(event.type); } },
} });
console.log(await agent.run({ name: 'Ivan' }));
js
import { AgentCoreEngine, defineWorkflow, route } from '@jangts/agent-core/engine';
const workflow = defineWorkflow({ id: 'greeting', nodes: [{
            id: 'greet', description: '生成问候', startsRound: true,
            run(state, context) {
                context.report({ payload: { phase: 'formatting' } });
                return { answer: '你好,' + state.name };
            }, routes: [route.deliver('answer')],
        }] });
const agent = new AgentCoreEngine({ workflow, execution: {
        observe: { event(event) { console.log(event.type); } },
    } });
console.log(await agent.run({ name: 'Ivan' }));

API reference, usage examples and developer guides.