PrefectHQ / ControlFlow

🦾 Take control of your AI agents
https://controlflow.ai
Apache License 2.0
337 stars 15 forks source link

Docs: Task Dependency Example in Tutorial Not Working as Described #195

Open taylor-curran opened 2 days ago

taylor-curran commented 2 days ago

The task dependency example in the ControlFlow documentation under the "Hello, tasks" section isn't functioning as expected. Here are the issues:

When Running the Example Code as Provided:

import controlflow as cf
from pydantic import BaseModel

class Name(BaseModel):
    first: str
    last: str

name = cf.Task("Get the user's name", user_access=True, result_type=Name)
poem = cf.Task("Write a personalized poem", context=dict(name=name))

poem.run()

Outcome : The process hangs indefinitely, requiring a manual interrupt.

When Running the Tasks Explicitly in Sequence:

I'm not sure if this is the correct way to run these outside of a flow...

name.run()
poem.run()

Outcome : The name task runs successfully, but the poem task throws an error:

RuntimeError: dictionary changed size during iteration

This contradicts the docs, which state:

"ControlFlow will automatically run any dependencies before executing the task you requested. In the above example, we only ran the poem task, but ControlFlow automatically ran the name task first, then passed its result to the poem task's context. We can see that both tasks were successfully completed and have result values."

Environment: