Manage conversation history and threads
ControlFlow provides powerful mechanisms for managing conversation history and creating private threads within your AI workflows. This guide will help you understand how to leverage these features to create more sophisticated and context-aware applications.
In ControlFlow, each Flow
maintains its own conversation history. This history includes all the interactions, decisions, and outputs generated during the execution of tasks within that flow. By default, this history is used to provide context for subsequent tasks, allowing for coherent and context-aware conversations.
When you create a new Flow
, it automatically generates a new thread with a unique ID. This thread isolates the conversation history for that particular flow.
You can also create a flow with a specific thread ID, which is useful for resuming conversations or creating deterministic threads:
To resume a previous conversation, you can create a new flow with the same thread ID:
Sometimes you may want to create a private conversation that doesn’t affect the main thread. You can do this by creating a new flow within your current flow. The events in the private flow won’t be visible to the parent flow.
One reason to create private threads is to perform activities that would otherwise pollute the context for all agents, like loading and summarizing data in a file. By creating a private thread, you can have an agent load a file into its context and produce a summary, then use only the summary in the parent flow. None of the other agents will have to endure the token or time cost of loading the file.
By default, when you create a new flow within another flow, it inherits the history of its parent:
If you want to completely isolate a sub-flow’s history from its parent, you can set load_parent_events=False
:
Manage conversation history and threads
ControlFlow provides powerful mechanisms for managing conversation history and creating private threads within your AI workflows. This guide will help you understand how to leverage these features to create more sophisticated and context-aware applications.
In ControlFlow, each Flow
maintains its own conversation history. This history includes all the interactions, decisions, and outputs generated during the execution of tasks within that flow. By default, this history is used to provide context for subsequent tasks, allowing for coherent and context-aware conversations.
When you create a new Flow
, it automatically generates a new thread with a unique ID. This thread isolates the conversation history for that particular flow.
You can also create a flow with a specific thread ID, which is useful for resuming conversations or creating deterministic threads:
To resume a previous conversation, you can create a new flow with the same thread ID:
Sometimes you may want to create a private conversation that doesn’t affect the main thread. You can do this by creating a new flow within your current flow. The events in the private flow won’t be visible to the parent flow.
One reason to create private threads is to perform activities that would otherwise pollute the context for all agents, like loading and summarizing data in a file. By creating a private thread, you can have an agent load a file into its context and produce a summary, then use only the summary in the parent flow. None of the other agents will have to endure the token or time cost of loading the file.
By default, when you create a new flow within another flow, it inherits the history of its parent:
If you want to completely isolate a sub-flow’s history from its parent, you can set load_parent_events=False
: