Sequential Workflows

Linear, deterministic processes where each step depends on the output of the previous step.

Sequential workflows ensure predictable execution order and clear data flow between steps.

Example Flow: Research → Data Processing → Content Creation → Final Review

Sequential workflows ensure predictable execution order and clear data flow between steps.

1from kern.workflow import Step, Workflow, StepOutput
2
3def data_preprocessor(step_input):
4 # Custom preprocessing logic
5
6 # Or you can also run any agent/team over here itself
7 # response = some_agent.run(...)
8 return StepOutput(content=f"Processed: {step_input.input}") # <-- Now pass the agent/team response in content here
9
10workflow = Workflow(
11 name="Mixed Execution Pipeline",
12 steps=[
13 research_team, # Team
14 data_preprocessor, # Function
15 content_agent, # Agent
16 ]
17)
18
19workflow.print_response("Analyze the competitive landscape for fintech startups", markdown=True)
Note

For more information on how to use custom functions, refer to the Workflow with custom function step page.

See Example:

Note

StepInput and StepOutput provides standardized interfaces for data flow between steps: So if you make a custom function as an executor for a step, make sure that the input and output types are compatible with the StepInput and StepOutput interfaces. This will ensure that your custom function can seamlessly integrate into the workflow system.

Take a look at the schemas for StepInput and StepOutput.