Skip to content

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.

readonly memoryScopeWithSuffix: (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.

string

string


readonly parentStepId: string | null

Defined in: packages/core/src/workflow/types.ts:58


readonly parentWorkflowRunId: 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.


readonly rootWorkflowRunId: 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.


readonly runLocalScope: (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.

string

string


readonly signal: 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.


readonly stepId: string | null

Defined in: packages/core/src/workflow/types.ts:56


readonly stepPath: string[]

Defined in: packages/core/src/workflow/types.ts:57


readonly workflowRunId: string

Defined in: packages/core/src/workflow/types.ts:44

Id of this workflow invocation (shared by all steps/agents in the run).

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.

readonly string[]


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.

string

unknown

void


noteMemoryScopeAccessed(memoryScope): void

Defined in: packages/core/src/workflow/types.ts:97

Record a scope this frame touched. The runtime message store calls this.

string

void


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).

unknown

Promise<void>


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.

string

Promise<void>