hostedagentmodels

package
v0.26.0-alpha1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 9 Imported by: 0

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

View Source
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

AllAPIs is every protocol a harness may declare.

Functions

func APIsFor

func APIsFor(provider, dialect string) []string

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.

func Default

func Default(ctx context.Context, client kclient.Client, namespace string, models []Model) string

Default returns the model to reach for, following the installation's llm alias and falling back to the first listed.

func ProxyPath

func ProxyPath(provider string) (string, bool)

ProxyPath is the segment of Obot's LLM proxy route that serves a provider.

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.

func (Model) Speaks

func (m Model) Speaks(api string) bool

Speaks reports whether this model accepts the given protocol. An empty protocol means the caller has no requirement, which nothing fails.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL