# HostedToolContext

> 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.hostedtoolcontext/
> Summary: HostedToolContext: What the factory of a hosted tool (AddHostedTool) learns about the agent it builds the tool for.

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

What the factory of a hosted tool (`AddHostedTool`) learns about the agent it builds the
tool for.

```csharp
public sealed class HostedToolContext
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.hostedtoolcontext/">HostedToolContext</a></dd><dt>Inherited Members</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a></dd></dl>

## Remarks

The factory runs on every run of an agent that selects the tool. Tracon calls it to compare what it
builds with the compiled agent in its cache, and compiles the agent again only when the two differ
(a new tenant, a new definition, a replaced vector store). Keep it cheap and free of side effects:
build the tool from values you already hold, and do not call the network.

A value that belongs to the tenant, for instance the identifier of the tenant's own vector
store, is read here by [HostedToolContext.TenantId](/api/tracon.hostedtoolcontext/#Tracon_HostedToolContext_TenantId). An identifier is not a `secret`; never put
a credential into a hosted tool.

## Constructors

### <a id="Tracon_HostedToolContext__ctor"></a> HostedToolContext\(\)

```csharp
public HostedToolContext()
```

## Properties

### <a id="Tracon_HostedToolContext_Provider"></a> Provider

Gets the name of the model provider of the agent's primary binding, for example
`openai-responses`.

```csharp
public required string Provider { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

#### Remarks

A fallback link receives the same tool, so a factory that returns a different tool for each
provider serves the primary binding only.

### <a id="Tracon_HostedToolContext_Services"></a> Services

Gets the host's root service provider.

```csharp
public required IServiceProvider Services { get; init; }
```

#### Property Value

 [IServiceProvider](https://learn.microsoft.com/dotnet/api/system.iserviceprovider)

### <a id="Tracon_HostedToolContext_TenantId"></a> TenantId

Gets the tenant the agent is compiled for.

```csharp
public required string TenantId { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)
