# IAgentDefinitionStore

> 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.iagentdefinitionstore/
> Summary: IAgentDefinitionStore: The store for agent definitions kept in the database. Versioning and rollback support are required: every save produces a new version, and old versions are not.

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

The store for agent definitions kept in the database. Versioning and rollback
support are required: every save produces a new version, and old versions are
not deleted.

```csharp
public interface IAgentDefinitionStore
```

## Remarks

**Tenant behavior — AMBIENT tenant.** No member takes a tenant
parameter; every method filters by the current `ITenantContext`
internally.

**Why this differs from `IAgentSkillStore`/`ISkillScriptGrantStore`.**
Those two sibling stores (added later, for the skills feature) take an
EXPECTED tenant as an explicit parameter on every method instead. Both
shapes filter correctly — there is no known cross-tenant leak from either
one — and there is no deeper design rule that decides which a given store
should use: this is a generational split, not a principled one. This store
followed the earlier convention shared with `IRunStore` and
`ISessionStore` (read `ITenantContext` internally); the skills
stores followed the convention shared with most later admin-CRUD stores
(an explicit parameter, no ambient fallback at all). A third-party
implementer must read each interface's own tenant-mode remarks rather than
assume consistency across a cluster.

## Methods

### <a id="Tracon_IAgentDefinitionStore_DeleteAsync_System_String_System_Threading_CancellationToken_"></a> DeleteAsync\(string, CancellationToken\)

Deletes the definition and every one of its versions. The numbering is kept: the
next save under this name continues it, so a version number a run, a workflow
node or an approval recorded before the delete never names another content.

```csharp
ValueTask<bool> DeleteAsync(string name, CancellationToken cancellationToken = default)
```

#### Parameters

`name` [string](https://learn.microsoft.com/dotnet/api/system.string)

The agent name.

`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)<[bool](https://learn.microsoft.com/dotnet/api/system.boolean)\>

[true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) when the delete happened.

### <a id="Tracon_IAgentDefinitionStore_GetAsync_System_String_System_Threading_CancellationToken_"></a> GetAsync\(string, CancellationToken\)

Returns the current version of the definition with the given name.

```csharp
ValueTask<AgentDefinition?> GetAsync(string name, CancellationToken cancellationToken = default)
```

#### Parameters

`name` [string](https://learn.microsoft.com/dotnet/api/system.string)

The agent name.

`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)<[AgentDefinition](/api/tracon.agentdefinition/)?\>

The definition, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when it does not exist.

### <a id="Tracon_IAgentDefinitionStore_GetVersionAsync_System_String_System_Int32_System_Threading_CancellationToken_"></a> GetVersionAsync\(string, int, CancellationToken\)

Returns the given version of the definition with the given name.

```csharp
ValueTask<AgentDefinition?> GetVersionAsync(string name, int version, CancellationToken cancellationToken = default)
```

#### Parameters

`name` [string](https://learn.microsoft.com/dotnet/api/system.string)

The agent name.

`version` [int](https://learn.microsoft.com/dotnet/api/system.int32)

The requested version number.

`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)<[AgentDefinition](/api/tracon.agentdefinition/)?\>

The definition, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when that version does not exist.

### <a id="Tracon_IAgentDefinitionStore_ListAsync_System_Threading_CancellationToken_"></a> ListAsync\(CancellationToken\)

Lists the current version of every definition.

```csharp
ValueTask<IReadOnlyList<AgentDefinition>> ListAsync(CancellationToken cancellationToken = default)
```

#### Parameters

`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)<[IReadOnlyList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist\-1)<[AgentDefinition](/api/tracon.agentdefinition/)\>\>

The definitions.

### <a id="Tracon_IAgentDefinitionStore_ListVersionsAsync_System_String_System_Threading_CancellationToken_"></a> ListVersionsAsync\(string, CancellationToken\)

Lists every version of a definition, from newest to oldest.

```csharp
ValueTask<IReadOnlyList<AgentDefinition>> ListVersionsAsync(string name, CancellationToken cancellationToken = default)
```

#### Parameters

`name` [string](https://learn.microsoft.com/dotnet/api/system.string)

The agent name.

`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)<[IReadOnlyList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist\-1)<[AgentDefinition](/api/tracon.agentdefinition/)\>\>

The version history.

### <a id="Tracon_IAgentDefinitionStore_RollbackAsync_System_String_System_Int32_System_Threading_CancellationToken_"></a> RollbackAsync\(string, int, CancellationToken\)

Makes the given version current. A rollback does not delete the old version; it
saves its content as a new version, numbered the same way a save is.

```csharp
ValueTask<AgentDefinition> RollbackAsync(string name, int version, CancellationToken cancellationToken = default)
```

#### Parameters

`name` [string](https://learn.microsoft.com/dotnet/api/system.string)

The agent name.

`version` [int](https://learn.microsoft.com/dotnet/api/system.int32)

The version number to roll back to.

`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)<[AgentDefinition](/api/tracon.agentdefinition/)\>

The definition saved as the new version.

### <a id="Tracon_IAgentDefinitionStore_SaveAsync_Tracon_AgentDefinition_System_Threading_CancellationToken_"></a> SaveAsync\(AgentDefinition, CancellationToken\)

Saves the definition and produces a new version. The
`AgentDefinition.Version` value of the incoming definition is ignored;
the store decides the version number. The version is one more than the highest
version this name ever had, including the versions of a definition that was
deleted: a version number is never reused for a name.

```csharp
ValueTask<AgentDefinition> SaveAsync(AgentDefinition definition, CancellationToken cancellationToken = default)
```

#### Parameters

`definition` [AgentDefinition](/api/tracon.agentdefinition/)

The definition to save.

`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)<[AgentDefinition](/api/tracon.agentdefinition/)\>

The definition with the new version number assigned.
