Skip to content

IConversationBranchStore

Namespace AgentPrism · Assembly AgentPrism.Abstractions.dll

The store that branches a conversation by copying it.

public interface IConversationBranchStore

Copying was chosen, not a pointer chain. If the new conversation only kept parent_conversation_id, every history read would be recursive; SqlChatHistoryProvider is the hottest read path, running on every agent turn, and this would charge a cost even to a consumer who never uses branching. With copying, the read path never changes. The pointer is only lineage information.

This interface is registered only when a SQL provider is enabled (UsePostgreSql, UseSqlServer, UseSqlite). In an in-memory setup, chat history lives inside Microsoft Agent Framework’s InMemoryChatHistoryProvider object, in the session state’s opaque block, and cannot be copied up to a specific sequence number. The endpoint returns 501 in this case — it does not silently copy the whole thing.

BranchAsync(string, Guid, long?, CancellationToken)

Section titled “ BranchAsync(string, Guid, long?, CancellationToken)”

Opens a new conversation by copying an existing one.

ValueTask<ConversationBranch?> BranchAsync(string tenantId, Guid parentConversationId, long? upToSequence, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

parentConversationId Guid

The source conversation.

upToSequence long?

The sequence number of the last item to include. If null, the whole conversation is copied.

cancellationToken CancellationToken

The cancellation token.

ValueTask<ConversationBranch?>

The new conversation’s identifier, the branch point, and the number of items copied; null if the source conversation does not exist or belongs to another tenant.