TLDR: set interactive=True to chat with your agents.

ControlFlow agents are primarily designed to solve problems by working autonomously. However, there are situations where user input is necessary to guide the agent’s decision-making process. By incorporating user input into your ControlFlow workflows, you can create more dynamic, interactive AI applications that adapt to user needs in real-time.

By default, agents are not able to interact with users directly. To allow it, you need to explicitly enable user access, either at the task or agent level. If applied to a task, all assigned agents will be able to interact with the user. If applied to an agent, the agent will be able to interact with the user in all of its tasks.

When interactive=True, the agent is given a tool for that it can use to send messages to the user. The user can then respond to these messages, and the agent can use the responses to make decisions or perform actions. By default, ControlFlow collects inputs directly in your terminal, but input can also be sent remotely via the Prefect API.

Interactive tasks

If a task is marked as interactive, then all agents assigned to the task will be allowed to interact with the user.

import controlflow as cf

color = cf.run(
    "Get the user's favorite color",
    interactive=True,
)

print(f"The user's favorite color is: {color}")

Interactive agents

If an agent is marked as interactive, then it will be allowed to interact with the user in every task it’s assigned to, even if the task is not marked as interactive.

import controlflow as cf

agent = cf.Agent(
    "Chatbot",
    interactive=True,
)

agent.run("Get the user's favorite color")