Configuring a Default Agent
Set global and flow-specific defaults.
ControlFlow uses a default agent when no specific agents are assigned to a task. Understanding how to configure and override this default agent at different levels can help you create more flexible and customized workflows.
Changing the Global Default Agent
The global default agent (whose name, of course, is Marvin) uses whatever default model you’ve configured. It has a basic set of general-purpose instructions and is not equipped with any tools.
To change the global default agent, assign a new agent to controlflow.defaults.agent
:
Changing a Flow’s Default Agent
You can also set a default agent for a specific flow. by using its default_agent
parameter when decorating your flow function or creating the flow object.
In this example, both the research_task
and writing_task
will use the researcher
and writer
agents by default.
Agent Selection Precedence
When ControlFlow needs to assign an agent to a task, it follows this precedence:
- Agents specified directly on the task (
task.agents
) - The agent specified by the flow (
@flow(default_agent=...)
) - The global default agent (
controlflow.defaults.agent
)
This means you can always override the default agent by specifying agents directly on a task, regardless of what default agents are set at the flow or global level.
In this example:
task1
will use theflow_agent
task2
will use thetask_agent
task3
will use theglobal_agent
By understanding and utilizing these different levels of agent configuration, you can create more flexible and customized workflows in ControlFlow.