Skip to main content

ControlFlow Banner

ControlFlow

ControlFlow is a Python framework for building agentic AI workflows.

ControlFlow provides a structured, developer-focused framework for defining workflows and delegating work to LLMs, without sacrificing control or transparency:

  • Create discrete, observable tasks for an AI to work on.
  • Assign one or more specialized AI agents to each task.
  • Combine tasks into a flow to orchestrate more complex behaviors.

Example

The simplest ControlFlow workflow has one task, a default agent, and automatic thread management:

import controlflow as cf

result = cf.run("Write a short poem about artificial intelligence")

print(result)

Result:

In circuits and code, a mind does bloom,
With algorithms weaving through the gloom.
A spark of thought in silicon's embrace,
Artificial intelligence finds its place.

Why ControlFlow?

ControlFlow addresses the challenges of building AI-powered applications that are both powerful and predictable:

  • 🧩 Task-Centric Architecture: Break complex AI workflows into manageable, observable steps.
  • 🔒 Structured Results: Bridge the gap between AI and traditional software with type-safe, validated outputs.
  • 🤖 Specialized Agents: Deploy task-specific AI agents for efficient problem-solving.
  • 🎛️ Flexible Control: Continuously tune the balance of control and autonomy in your workflows.
  • 🕹️ Multi-Agent Orchestration: Coordinate multiple AI agents within a single workflow or task.
  • 🔍 Native Observability: Monitor and debug your AI workflows with full Prefect 3.0 support.
  • 🔗 Ecosystem Integration: Seamlessly work with your existing code, tools, and the broader AI ecosystem.

Installation

Install ControlFlow with pip:

pip install controlflow

Next, configure your LLM provider. ControlFlow's default provider is OpenAI, which requires the OPENAI_API_KEY environment variable:

export OPENAI_API_KEY=your-api-key

To use a different LLM provider, see the LLM configuration docs.

Workflow Example

Here's a more involved example that showcases user interaction, a multi-step workflow, and structured outputs:

import controlflow as cf
from pydantic import BaseModel


class ResearchProposal(BaseModel):
    title: str
    abstract: str
    key_points: list[str]


@cf.flow
def research_proposal_flow():

    # Task 1: Get the research topic from the user
    user_input = cf.Task(
        "Work with the user to choose a research topic",
        interactive=True,
    )
    
    # Task 2: Generate a structured research proposal
    proposal = cf.run(
        "Generate a structured research proposal",
        result_type=ResearchProposal,
        depends_on=[user_input]
    )
    
    return proposal


result = research_proposal_flow()

print(result.model_dump_json(indent=2))
Click to see results

Conversation:

Agent: Hello! I'm here to help you choose a research topic. Do you have 
any particular area of interest or field you would like to explore? 
If you have any specific ideas or requirements, please share them as well.

User: Yes, I'm interested in LLM agentic workflows

Proposal:

{
    "title": "AI Agentic Workflows: Enhancing Efficiency and Automation",
    "abstract": "This research proposal aims to explore the development and implementation of AI agentic workflows to enhance efficiency and automation in various domains. AI agents, equipped with advanced capabilities, can perform complex tasks, make decisions, and interact with other agents or humans to achieve specific goals. This research will investigate the underlying technologies, methodologies, and applications of AI agentic workflows, evaluate their effectiveness, and propose improvements to optimize their performance.",
    "key_points": [
        "Introduction: Definition and significance of AI agentic workflows, Historical context and evolution of AI in workflows",
        "Technological Foundations: AI technologies enabling agentic workflows (e.g., machine learning, natural language processing), Software and hardware requirements for implementing AI workflows",
        "Methodologies: Design principles for creating effective AI agents, Workflow orchestration and management techniques, Interaction protocols between AI agents and human operators",
        "Applications: Case studies of AI agentic workflows in various industries (e.g., healthcare, finance, manufacturing), Benefits and challenges observed in real-world implementations",
        "Evaluation and Metrics: Criteria for assessing the performance of AI agentic workflows, Metrics for measuring efficiency, accuracy, and user satisfaction",
        "Proposed Improvements: Innovations to enhance the capabilities of AI agents, Strategies for addressing limitations and overcoming challenges",
        "Conclusion: Summary of key findings, Future research directions and potential impact on industry and society"
    ]
}

In this example, ControlFlow is automatically managing a flow, or a shared context for a series of tasks. You can switch between standard Python functions and agentic tasks at any time, making it easy to incrementally build out complex workflows.

Learn More

To dive deeper into ControlFlow:

Metadata

Release files for controlflow 0.12.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for controlflow 0.12.1
File Size Uploaded
controlflow-0.12.1.tar.gz 1.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for controlflow 0.12.1
File Interpreter ABI Platform
controlflow-0.12.1-py3-none-any.whl Python 3 none any Details

Total release size: 1.8 MB

Release files / controlflow-0.12.1.tar.gz

Download URL controlflow-0.12.1.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
74f8b06932a7f0a3b13730f7e793cd36b5f0e13593ed985887e221243e7c232f
BLAKE2b-256 checksum
How to use checksums
27f66da44b0e489b151f9123413c198d12a0be3728ca239d64bf3d76c955c06a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 6, 2025.

Transparency log

Release files / controlflow-0.12.1-py3-none-any.whl

Download URL controlflow-0.12.1-py3-none-any.whl
Size 105.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e9ea4aa2d3f2f48477e5555c9e9b23ca8f20f480def2fd18c4963faf3cc26ec0
BLAKE2b-256 checksum
How to use checksums
42c7d3121e70c8e7d2a9f547b49e66c6f56e85b612834ab81ce6fa3d4b8d2c8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 6, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.12.1 This release

2 release files

0.11.4

2 release files

0.11.2

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.5

2 release files

0.7.4

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page