run_until
parameter to control the execution of a ControlFlow workflow. We’ll create a simple research workflow that stops under various conditions, showcasing the flexibility of this feature. In this case, we’ll allow research to continue until either two topics are researched or 15 LLM calls are made.
Code
Key Concepts
-
Custom Termination Conditions: We use a combination of
AnyComplete
andMaxLLMCalls
conditions to control when the workflow should stop. -
Flexible Workflow Control: By using termination conditions with the
run_until
parameter, we can create more dynamic workflows that adapt to different scenarios. In this case, we’re balancing between getting enough research done and limiting resource usage. -
Partial Results: The workflow can end before all tasks are complete, so we handle partial results by filtering for completed
ResearchPoint
objects. -
Combining Conditions: We use the
|
operator to combine multiple termination conditions. ControlFlow also supports&
for more complex logic.