Conversation branching for the agent session.
Allows rewinding to an earlier turn and trying a different prompt, creating a branch. Previous branches are preserved and can be revisited. This enables "what if" exploration without losing prior work.
Summary
Functions
Branches at the given turn index, saving the current messages as a named branch and returning the truncated message list.
Lists all branches with their names and message counts.
Creates a new branch from the given messages.
Types
@type t() :: %MingaAgent.Branch{ created_at: DateTime.t(), messages: [MingaAgent.Message.t()], name: String.t() }
A named conversation branch.
Functions
@spec branch_at([MingaAgent.Message.t()], non_neg_integer(), String.t(), [t()]) :: {:ok, [MingaAgent.Message.t()], [t()]} | {:error, String.t()}
Branches at the given turn index, saving the current messages as a named branch and returning the truncated message list.
Turn index is 0-based. Messages from index 0 to turn_index (inclusive)
are kept; the rest become the branch.
Lists all branches with their names and message counts.
@spec new(String.t(), [MingaAgent.Message.t()]) :: t()
Creates a new branch from the given messages.