ControlFlow
ControlFlow copied to clipboard
`cf.run_tasks()` does not create a flow
Description
Running Tasks docs say that with cf.run_tasks() "All of the tasks will be run as part of the same flow (if you are not already operating in a flow context), ..."
I'm not observing that behavior with the code snippet below.
A flow run is created if you use the @cf.flow decorator.
Example Code
import controlflow as cf
from langchain_community.tools import DuckDuckGoSearchRun
summarizer = cf.Agent(
name="Headline Summarizer",
instructions="An AI agent that fetches and summarizes current events",
tools=[DuckDuckGoSearchRun()],
)
extractor = cf.Agent(
name="Entity Extractor",
instructions="An AI agent that does named entity recognition",
)
# @cf.flow() # uncomment and the flow is created
def get_headlines():
summarizer_task = cf.Task(
"Retrieve and summarize today's two top business headlines",
agents=[summarizer],
result_type=list[str],
)
extractor_task = cf.Task(
"Extract any fortune 500 companies mentioned in the headlines and whether the sentiment is positive, neutral, or negative",
agents=[extractor],
depends_on=[summarizer_task],
)
results = cf.run_tasks([summarizer_task, extractor_task])
return results
if __name__ == "__main__":
results = get_headlines()
print(results)
Version Information
ControlFlow version: 0.11.0
Prefect version: 3.0.10
LangChain Core version: 0.3.12
Python version: 3.12.2
Platform: macOS-15.0.1-arm64-arm-64bit
Path: /opt/homebrew/Caskroom/miniforge/base/lib/python3.12
### Additional Context
_No response_