Skip to main content

defineEntrypoint

workflow.defineEntrypoint<Input, Output>() defines an independently runnable entrypoint in a Workflow project. Each entrypoint has its own workflow, parameters, input construction, tools, token-usage settings, debug registry, and context extensions. Once the platform selects an entrypoint, it runs only that entrypoint; it does not run the default entrypoint first.

Entrypoints are a flat set of runnable targets in one project, not parent-child calls. To compose several business workflows into one run, explicitly call workflow.runWorkflow() from a workflow.

Signature

workflow.defineEntrypoint<Input, Output>(
definition: WorkflowEntrypointDefinition<Input, Output>,
): WorkflowEntrypointDefinition<Input, Output>

Fields

FieldTypeDescription
idstringA project-unique entrypoint ID matching /^[a-z][a-z0-9_-]{0,63}$/.
titlestringA non-empty display title used by Desktop, Server Web, Embed, logs, and replay.
descriptionstringAn optional entrypoint description.
workflowWorkflowDefinition<Input, Output>The workflow executed by this entrypoint. Required.
paramsWorkflowParamDefinition[]Structured parameters for this entrypoint.
createInput(context) => InputConverts this entrypoint's arguments and paramValues into workflow input. Required.
resolveParams(context) => WorkflowParamResolveResultParameter-resolution callback for this entrypoint.
requiredProvidersExecutorProviderName[]Providers required by this entrypoint. The only built-in name is currently "llm".
toolsWorkflowToolPermissionDefinition[]Tools this entrypoint may invoke and their default approval policy.
tokenUsageWorkflowTokenUsageDefinitionToken-usage reporting configuration for this entrypoint.
registryWorkflowNodeRegistryEntry[]Nodes that can be debugged separately for this entrypoint.
createContext(context) => Partial<WorkflowContext>Adds providers, metadata, and hooks for this entrypoint. KV, PersistentValue, conversation, and files remain runtime-provided.

createInput, resolveParams, each registry entry's createInput, and createContext receive a WorkflowExecutorContext. When a Workflow entrypoint runs, entrypointId and entrypointTitle identify the selected entrypoint. The runtime also writes those values to WorkflowContext.metadata, runtime events, and the final report.

Executor declaration

A Workflow executor must declare a static default entrypoint and a non-empty entrypoint array:

export const executor = workflow.defineExecutor({
projectType: "workflow",
defaultEntrypoint: "main",
entrypoints: [
workflow.defineEntrypoint<MainInput, MainOutput>({
id: "main",
title: "Full workflow",
workflow: mainWorkflow,
params: [],
createInput() {
return { errCode: 0, errMessage: "" };
},
}),
workflow.defineEntrypoint<ValidateInput, ValidateOutput>({
id: "validate",
title: "Data validation",
description: "Runs only the validation stage.",
workflow: validateWorkflow,
params: [],
createInput() {
return { errCode: 0, errMessage: "" };
},
}),
],
});

When the caller does not select an entrypoint, the runtime runs defaultEntrypoint. Selecting validate explicitly runs only validateWorkflow; mainWorkflow does not run first.

Static structure rules

workflow-code structure does not execute configuration code, so it must be able to read the entrypoint declaration statically:

  • entrypoints must be a non-empty array literal.
  • Each item must directly call workflow.defineEntrypoint({ ... }).
  • id, title, optional description, and defaultEntrypoint must be static strings.
  • workflow must reference an identifier defined with workflow.defineWorkflow(...) in the project source. You can use named, aliased, or default imports through a relative path in the project. Structure resolves the actual import/export binding. An unreferenced same-name definition, a value from an external package, or a dynamically constructed value produces a violation.
  • IDs must be valid and unique, and defaultEntrypoint must identify one of them.
  • A Workflow executor no longer accepts top-level workflow, params, createInput, resolveParams, requiredProviders, tools, tokenUsage, registry, or createContext. Move these fields to their specific entrypoint.

The structure report exposes defaultEntrypoint and entrypoints[] at project level. Every entrypoint contains id, title, optional description, workflowName, execution, params, paramResolver, tools, tokenUsage, and registry. Workflow projects no longer expose compatible top-level params or execution fields, and do not aggregate individual registries into definitions.registry.

State and isolation

Entrypoints isolate execution configuration and UI drafts, not project data scope:

DataBehavior
Run, report, and historyEach run records the actual entrypoint ID and a title snapshot.
Parameter, attachment, and tool-policy draftsHosts isolate them by project, resolution target, and entrypoint.
Registry and debug nodeOnly the selected entrypoint's registry is available.
context.storage.local/serverEntrypoints in the same project continue to share the workflow namespace at each location. Design your own keys when business isolation is required.
ConversationDoes not use defineEntrypoint and does not accept entrypoint selection.

Errors

SituationError typeDescription
Invalid ID, empty title, or duplicate entrypointinput_validationThe runtime rejects the definition and structure reports the violation.
Default entrypoint does not existinput_validationThe executor cannot load.
Unknown entrypoint requestedinput_validationError metadata includes the default entrypoint and allowed entrypoints.
Conversation receives an entrypoint argumentinput_validationConversation remains single-entry; the argument is neither ignored nor silently redirected.