WorkflowContext
Defined in: packages/core/src/workflow/types.ts:42
Workflow execution scope. Implemented by WorkflowContextImpl (class); prefer
ctx.step(...) on the instance. Bound methods are arrow fields, so destructuring is safe.
Passed to the workflow author’s run function. Callers may pass parentCtx
on Workflow#run to nest under a parent run; otherwise the runtime supplies context.
Properties
Section titled “Properties”memoryScopeWithSuffix
Section titled “memoryScopeWithSuffix”
readonlymemoryScopeWithSuffix: (suffix) =>string
Defined in: packages/core/src/workflow/types.ts:81
Build a AgentRunInput.memoryScope namespaced to the root of this
nest tree: ${rootWorkflowRunId}:${suffix}.
Nested workflow.run() phases that share a suffix therefore share one
transcript. Use runLocalScope when the conversation must stay on
this immediate run only. { isolated: true } starts its own root, so its
scopes do not join the caller’s tree.
Parameters
Section titled “Parameters”suffix
Section titled “suffix”string
Returns
Section titled “Returns”string
parentStepId
Section titled “parentStepId”
readonlyparentStepId:string|null
Defined in: packages/core/src/workflow/types.ts:58
parentWorkflowRunId
Section titled “parentWorkflowRunId”
readonlyparentWorkflowRunId:string|null
Defined in: packages/core/src/workflow/types.ts:49
Immediate parent run when this invocation nested under another workflow;
null for top-level and { isolated: true } runs.
rootWorkflowRunId
Section titled “rootWorkflowRunId”
readonlyrootWorkflowRunId:string
Defined in: packages/core/src/workflow/types.ts:55
Outermost run id of this nest tree. Equals workflowRunId when
parentWorkflowRunId is null (top-level and { isolated: true }).
Nested contexts inherit the parent’s value — no store walk.
runLocalScope
Section titled “runLocalScope”
readonlyrunLocalScope: (suffix) =>string
Defined in: packages/core/src/workflow/types.ts:88
Build a AgentRunInput.memoryScope namespaced to this workflow run:
${workflowRunId}:${suffix}. Nested phases with the same suffix get separate
conversations. Prefer memoryScopeWithSuffix for cross-phase agents.
Parameters
Section titled “Parameters”suffix
Section titled “suffix”string
Returns
Section titled “Returns”string
signal
Section titled “signal”
readonlysignal:AbortSignal
Defined in: packages/core/src/workflow/types.ts:64
Aborts when WorkflowRunHandle.cancel is called on this run (or a parent
run that this invocation nested under). Passed into ctx.step bodies and linked
to child agent.run / agent.stream AbortControllers.
step:
StepFn
Defined in: packages/core/src/workflow/types.ts:70
Run a named, cacheable unit of work. Child contexts are built from the parent host
(this). Agent/tool bridge uses scoped ALS only inside step bodies and the workflow body.
stepId
Section titled “stepId”
readonlystepId:string|null
Defined in: packages/core/src/workflow/types.ts:56
stepPath
Section titled “stepPath”
readonlystepPath:string[]
Defined in: packages/core/src/workflow/types.ts:57
workflowRunId
Section titled “workflowRunId”
readonlyworkflowRunId:string
Defined in: packages/core/src/workflow/types.ts:44
Id of this workflow invocation (shared by all steps/agents in the run).
Methods
Section titled “Methods”accessedMemoryScopes()
Section titled “accessedMemoryScopes()”accessedMemoryScopes(): readonly
string[]
Defined in: packages/core/src/workflow/types.ts:94
Scopes this frame has loaded, saved, copied, or deleted through the runtime message store. A step frame’s list is also stored on that step’s record.
Returns
Section titled “Returns”readonly string[]
emit()
Section titled “emit()”emit(
name,payload?):void
Defined in: packages/core/src/workflow/types.ts:104
Emit a custom run event (type: "custom"). stepId on the persisted event is
omitted at workflow root (when WorkflowContext.stepId is null).
System lifecycle events cannot be authored this way.
Parameters
Section titled “Parameters”string
payload?
Section titled “payload?”unknown
Returns
Section titled “Returns”void
noteMemoryScopeAccessed()
Section titled “noteMemoryScopeAccessed()”noteMemoryScopeAccessed(
memoryScope):void
Defined in: packages/core/src/workflow/types.ts:97
Record a scope this frame touched. The runtime message store calls this.
Parameters
Section titled “Parameters”memoryScope
Section titled “memoryScope”string
Returns
Section titled “Returns”void
requestApproval()
Section titled “requestApproval()”requestApproval(
payload?):Promise<void>
Defined in: packages/core/src/workflow/types.ts:117
Park this run until import(”../stores/workflow-store”).WorkflowStore.resolveSuspend (inspector Allow/Deny or a programmatic resolve; debugger Continue never resolves it). Requires a workflow store. Deny throws; rewrite is rejected (approval is not a rewriteable tool).
Parameters
Section titled “Parameters”payload?
Section titled “payload?”unknown
Returns
Section titled “Returns”Promise<void>
setTitle()
Section titled “setTitle()”setTitle(
title):Promise<void>
Defined in: packages/core/src/workflow/types.ts:110
Set the inspector display title for this workflow run. Safe to call at the start
of run, after a first step, or just before returning — blank titles are ignored.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>