Documentation
¶
Overview ¶
Package hostedagentmodels resolves the models a hosted agent may use.
It exists because two callers need the same answer and must not disagree: the controller, which writes the resolved endpoints into a sandbox's config, and the API, which decides whether an agent can be launched at all. If the API said an agent was launchable and the controller then resolved no models, the user would get a sandbox that cannot do anything.
Index ¶
Constants ¶
const ( APIAnthropic = "anthropic" APIOpenAIResponses = "openai-responses" APIOpenAIChatCompletions = "openai-chat-completions" )
Wire protocols a model can be reached over.
These are distinct request and response formats, not vendors: a client written for the Responses API cannot talk to a chat-completions endpoint, and neither can talk to Anthropic's Messages API. Codex speaks Responses, Claude Code speaks Messages, and a library such as LiteLLM speaks chat completions -- so this is what decides whether a given harness can use a given model.
Variables ¶
var AllAPIs = []string{APIAnthropic, APIOpenAIResponses, APIOpenAIChatCompletions}
AllAPIs is every protocol a harness may declare.
Functions ¶
func APIsFor ¶
APIsFor reports the protocols a model accepts.
A declared dialect is authoritative and narrows the model to exactly one protocol, which is how an administrator states that an endpoint serves only one. Without a declaration the provider decides, and OpenAI-shaped providers are credited with both OpenAI protocols: their endpoints generally serve both, and being too narrow here would hide a model that works. Being too broad fails later at the endpoint, with an error naming the format -- which is the better failure of the two.
Types ¶
type Model ¶
type Model struct {
ID string
Model string
Provider string
// APIs is every protocol this model accepts. A model is usually reachable
// over more than one -- an OpenAI endpoint serves both Responses and chat
// completions -- so a single value would exclude clients that would work.
APIs []string
// Dialect is what the model declares, empty when it declares nothing.
Dialect string
}
Model is one usable model: resolved to a concrete target, a provider, and the protocols it can be reached over.
func Resolve ¶
func Resolve(ctx context.Context, client kclient.Client, namespace string, selections, providers []string) ([]Model, error)
Resolve turns an agent's model selections into the models it can actually use. A selection is a model ID, an "obot://<alias>" reference, the id a provider itself uses ("claude-opus-4-8"), or "*" for everything the installation has.
Order is meaningful: selections are added in the order given, and the wildcard last, so a template can list the models it prefers and fall back to whatever exists. Default reads the first entry when the installation's alias names nothing the agent may use, which is what turns that fallback from an arbitrary choice into a stated one.
providers, when non-empty, restricts the result to models from those model providers, named by their stable identifier.
A selection that resolves to nothing is skipped rather than failing: an agent may have several, and an alias can be unbound on a fresh install. The result is therefore what is genuinely usable, which is what both callers need.