TaskFlow
Orchestrate multi-step agent workflows with retry, input resolution, and parallel execution.
Overview
TaskFlow
is a flexible, agent-based orchestration utility designed for chaining and executing multiple AI agents in a structured, sequential, or parallel fashion.
It supports:
- Step-based and parallel execution of agents
- Dynamic input mapping with references to prior outputs
- Retry policies per step or globally
- Output tracking and structured result return
- Optional callbacks on step completion
TaskFlow
is a powerful orchestration engine designed to coordinate multiple AI agents and tools in a structured sequence or parallel execution pattern. It enables complex LLM pipelines with dynamic input resolution, retries, and step-by-step control.
✨ Features
- Step-by-step agent orchestration
- Input templating using
{{agent_name.key}}
- Parallel execution support
- Retry policy for each step
- Optional callbacks after steps
- Full flow trace access
🧠 Example Use Case
Let’s define a flow to extract information and summarize it.
1. Define Agents
2. Compose the TaskFlow
3. Run It
🧩 Dynamic Input Mapping
You can reference any previous step’s output using:
{{input}}
: Original input{{agent_name.key}}
: Output from a specific agent
Example:
🔁 Retry on Failure
Set retry policy for resilience:
Or globally:
⚡ Parallel Execution
Run steps concurrently if independent:
🔔 Callbacks
Hook into each step:
🧪 Output Structure
🆕 New Features
🔁 Advanced Step Controls
Each step()
now supports fine-grained execution control:
step_name
: Define a custom name for the step (useful for reusing agents).timeout
: Set a timeout in seconds for the step.on_start
,on_complete
,on_error
: Step-level hooks for better control and observability.condition
: A boolean-returning function to decide whether the step should run.depends_on
: Specify other steps that must complete before this one runs.
Example:
🏷️ Alias Creation
You can now define aliases for specific keys in a step’s output. This makes your input mappings cleaner and more maintainable.
Usage:
Instead of referencing {{summarizer.text}}
, you can now use the simplified {{summary}}
.
✅ Best Practices
- Keep agents focused (1 purpose per agent)
- Reuse tools through agents
- Use retries on weak/volatile steps
- Combine TaskFlow with UI or APIs
🛠 Tool-Based Agent Example
📘 Interface Summary (TS)
🎯 Use Case Ideas
Use Case | Description |
---|---|
Research Bot | Search → summarize → report |
Support Assistant | Classify → fetch KB → reply |
Market Analysis | Scrape → analyze → visualize |
Workflow Engine | Multi-agent automation with retries |
TaskFlow
brings composability and robustness to AI-based systems. Use it to turn isolated agents into scalable intelligent workflows.