# IConversationBranchStore

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.iconversationbranchstore/
> Summary: IConversationBranchStore: The store that branches a conversation by copying it.

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.Abstractions.dll</code></div>

The store that branches a conversation by copying it.

```csharp
public interface IConversationBranchStore
```

## Remarks

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

**DI lifetime — singleton.** Registered as a singleton with
`TryAdd`; a consumer's own registration wins.

## Methods

### <a id="Tracon_IConversationBranchStore_BranchAsync_System_String_System_Guid_System_Nullable_System_Int64__System_Threading_CancellationToken_"></a> BranchAsync\(string, Guid, long?, CancellationToken\)

Opens a new conversation by copying an existing one.

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

`tenantId` [string](https://learn.microsoft.com/dotnet/api/system.string)

The tenant identifier.

`parentConversationId` [Guid](https://learn.microsoft.com/dotnet/api/system.guid)

The source conversation.

`upToSequence` [long](https://learn.microsoft.com/dotnet/api/system.int64)?

The sequence number of the last item to include. If
[null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), the whole conversation is copied.

`cancellationToken` [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

The cancellation token.

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask\-1)<[ConversationBranch](/api/tracon.conversationbranch/)?\>

The new conversation's identifier, the branch point, and the number of
items copied; [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if the source conversation does
not exist or belongs to another tenant.
