Skip to main content
from definable.agent.workflow import Workflow, Step, Steps, Parallel, Loop, Condition, Router

Workflow

ParameterTypeDefaultDescription
namestrWorkflow name.
stepsList[Step]Step list (sequential by default).
session_stateDictNoneShared state across steps.
MethodReturnsDescription
arun(input, **kwargs)WorkflowOutputExecute the workflow.

WorkflowOutput

FieldTypeDescription
contentstrFinal step’s content.
successboolAll steps succeeded.
duration_msfloatTotal execution time.
step_outputsList[StepOutput]Per-step results.
get_step_output(name)StepOutputGet specific step result.

Step

ParameterTypeDefaultDescription
namestrStep name (used for result access).
agentAgentNoneAgent executor. Mutually exclusive with team, executor.
teamTeamNoneTeam executor.
executorCallableNoneCustom callable (StepInput) -> str.
timeoutfloatNoneMax execution seconds.
retriesint0Retry attempts.
input_builderCallableNoneCustom prompt builder.

Steps (Sequential)

ParameterTypeDescription
stepsList[Step]Steps executed in order with context chaining.

Parallel

ParameterTypeDefaultDescription
namestrGroup name.
stepsList[Step]Steps executed concurrently.
max_concurrencyintNoneLimit concurrent steps.

Loop

ParameterTypeDefaultDescription
namestrLoop name.
stepsList[Step]Steps per iteration.
end_conditionCallable(List[StepOutput]) -> bool. Return True to stop.
max_iterationsint3Max iterations.

Condition

ParameterTypeDefaultDescription
namestrCondition name.
conditionCallable(StepInput) -> bool.
true_stepsStep | List[Step]Steps when True.
false_stepsStep | List[Step]NoneSteps when False.

Router

ParameterTypeDescription
namestrRouter name.
selectorCallable(StepInput) -> str | List[str]. Returns route name(s).
routesDict[str, Step]Route name to step mapping.

StepInput

MethodReturnsDescription
inputstrOriginal workflow input.
get_last_step_content()strPrevious step’s output.
get_step_content(name)strSpecific step’s output by name.
session_stateDictShared session state.

Events

EventWhen
WorkflowRunStartedEventWorkflow begins.
WorkflowRunCompletedEventWorkflow completes.
WorkflowRunErrorEventWorkflow fails.
StepStartedEventStep begins.
StepCompletedEventStep completes.
StepErrorEventStep fails.
StepSkippedEventStep skipped.
LoopIterationEventLoop iteration completes.