Tasks: The Building Blocks
Tasks are the fundamental building blocks of ControlFlow workflows. Each task represents a discrete objective or goal that needs to be accomplished, such as generating text, classifying data, or extracting information from a document. Tasks define WHAT needs to be done in your AI workflow. Key characteristics of tasks include:- Clear objectives and expected result types
- Declarative definition of requirements and constraints
- Integration with traditional software through validated outputs
- Using the
Task
class for explicit definition of all task properties. - Using the
@task
decorator on Python functions, which automatically infers task properties from the function definition.
Agents: The Performers
Agents in ControlFlow are AI “workers” responsible for executing tasks. They determine HOW tasks are accomplished. Each agent can have distinct instructions, personality, and capabilities, tailored to specific roles or domains. Key aspects of agents include:- Specialized configuration for different types of tasks
- Access to specific tools or APIs
- Ability to interact with users and other agents when necessary
Flows: The Orchestrators
Flows are high-level containers that encapsulate and orchestrate entire AI-powered workflows. They provide a structured way to manage tasks, agents, tools, and shared context. Key features of flows include:- Maintaining a consistent state across all components
- Managing the execution order of tasks based on dependencies
- Providing a shared context for agent collaboration
Putting It All Together
When designing workflows in ControlFlow:- Break down your application logic into discrete tasks.
- Define the dependencies and relationships between tasks.
- Create specialized agents as needed for specific types of tasks.
- Use flows to orchestrate the execution of tasks and manage agent interactions.