Skip to content
Tracon

TenantChatClientCacheKey

Namespace Tracon · Assembly Tracon.Core.dll

Builds the cache key for an AI.IChatClient produced for a tenant credential (BYOK).

public static class TenantChatClientCacheKey

objectTenantChatClientCacheKey

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

The SDK client behind a ModelProviderCredential is built once and cached by Tracon.ProviderCredentialClientCache — it owns an HTTP connection pool and is expensive. The lightweight IChatClient wrapper a provider factory hands back from that client is cheap to allocate, but a caller that builds one and holds on to it must get the same instance back for the same credential and the same observable binding, not a fresh wrapper every call — the guarantee ModelProviderCredentialContract (in the published Tracon.Testing.Contracts.Xunit package) requires. The setup-time (no-credential) path gives no such guarantee: the four shipped factories’ CreateChatClient(ModelBinding) methods build a fresh wrapper on every call there too, and only the underlying SDK client — not the wrapper — is shared.

Two bindings produce the same wrapper’s inputs when they name the same model and carry the same provider settings: every one of the four shipped factories’ CreateChatClient(ModelBinding) methods reads only ModelBinding.Model and ModelBinding.ProviderSettings to build the wrapper — every other ModelBinding field either does not affect construction or is applied later, in ModelProviderRegistry’s pipeline.

Entries in the cache this key is used with are never evicted, the same trade-off Tracon.ProviderCredentialClientCache documents: the number of distinct (credential, model, settings) combinations is bounded by what an operator’s tenants actually use, not by request volume.

For(ModelProviderCredential, ModelBinding)

Section titled “ For(ModelProviderCredential, ModelBinding)”

Builds the cache key for a credential and a binding.

public static string For(ModelProviderCredential credential, ModelBinding binding)

credential ModelProviderCredential

The resolved tenant credential.

binding ModelBinding

The binding the client is produced for.

string

A key stable across calls with observably identical inputs.

ArgumentNullException

A parameter is null.