Skip to content
Tracon

HostedToolContext

Namespace Tracon · Assembly Tracon.Abstractions.dll

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

public sealed class HostedToolContext
Inheritance
object ← HostedToolContext
Inherited Members
object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

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. An identifier is not a secret; never put a credential into a hosted tool.

public HostedToolContext()

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

public required string Provider { get; init; }

string

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

Gets the host’s root service provider.

public required IServiceProvider Services { get; init; }

IServiceProvider

Gets the tenant the agent is compiled for.

public required string TenantId { get; init; }

string