MingaAgent.Branch (Minga v0.1.0)

Copy Markdown View Source

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

Types

t()

A named conversation branch.

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

t()

@type t() :: %MingaAgent.Branch{
  created_at: DateTime.t(),
  messages: [MingaAgent.Message.t()],
  name: String.t()
}

A named conversation branch.

Functions

branch_at(messages, turn_index, branch_name, existing_branches)

@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.

list(branches)

@spec list([t()]) :: String.t()

Lists all branches with their names and message counts.

new(name, messages)

@spec new(String.t(), [MingaAgent.Message.t()]) :: t()

Creates a new branch from the given messages.