Documentation Index
Fetch the complete documentation index at: https://docs.definable.ai/llms.txt
Use this file to discover all available pages before exploring further.
The simplest workflow pattern. Steps execute in order, each receiving context from the previous step.
from definable.agent import Agent
from definable.agent.workflow import Workflow, Step
researcher = Agent(model="gpt-4o", instructions="Research the given topic thoroughly.")
writer = Agent(model="gpt-4o", instructions="Write a clear article based on the research provided.")
editor = Agent(model="gpt-4o", instructions="Polish and improve the article.")
workflow = Workflow(
name="content-pipeline",
steps=[
Step(name="research", agent=researcher),
Step(name="write", agent=writer),
Step(name="edit", agent=editor),
],
)
result = await workflow.arun("The future of AI agents")
print(result.content) # Final edited article
How It Works
research step receives the original input (“The future of AI agents”).
write step receives the researcher’s output as context.
edit step receives the writer’s output as context.
result.content contains the editor’s final output.
Using Steps (Explicit Sequential)
For clarity, you can use the Steps wrapper:
from definable.agent.workflow import Workflow, Steps, Step
workflow = Workflow(
name="pipeline",
steps=[
Steps(steps=[
Step(name="research", agent=researcher),
Step(name="write", agent=writer),
]),
Step(name="edit", agent=editor),
],
)
Override how context is passed between steps:
def build_writer_input(ctx):
research = ctx.get_step_content("research")
return f"Based on this research, write a 500-word article:\n\n{research}"
Step(name="write", agent=writer, input_builder=build_writer_input)