Documentation
¶
Overview ¶
Package model defines the model vendors (Anthropic, OpenAI) and their canonical models: provider-qualified ids, the harnesses each model can be driven by, and per-token pricing.
It is a leaf domain package (it imports no other internal package), so both the controllers and the in-pod agent-runner can share one source of truth for which harness runs a model and what CLI model-id that harness expects. A model's identity (its provider-qualified ID) is independent of the executing harness: the Supported map records the harness-specific CLI id each driver needs, and Preferred names the default driver. The harness package layers resolution (ResolveModel/ValidateAllowlist) on top, filtering by which harnesses are enabled in a given deployment.
Model ids resolve in three tiers (Resolve / Lookup):
- exact: a registered canonical id ("anthropic/claude-opus-5-5");
- alias: a family alias with no version ("anthropic/claude-opus") resolves to the newest registered version of that family. Controllers resolve aliases once at startup (Canonicalize), so only the concrete id flows downstream (pod env, CRD status, rollups) and stats and pricing stay per-version;
- pattern: a well-formed but unregistered Anthropic version id ("anthropic/claude-opus-6") is synthesized as a claude-harness-only, unpriced model, so a new Anthropic release runs before patchy registers it. The claude CLI reports its own cost, so the missing rates matter only for display until the model is registered.
Index ¶
- Constants
- Variables
- func Canonicalize(ids []string) ([]string, error)
- func Concrete(id string) string
- func IsAlias(id string) bool
- func IsKnownHarnessID(id string) bool
- func IsProviderID(id string) bool
- func ParseClaudeID(bare string) (family string, major, minor int, ok bool)
- func Synthesized(m Model) bool
- func UsageCostUSD(m Model, inputTokens, cacheReadTokens, cacheCreationTokens, outputTokens int) *float64
- type Model
- type Provider
Constants ¶
const ( ProviderAnthropic = "anthropic" ProviderOpenAI = "openai" )
Provider ids.
const ( HarnessClaude = "claude" HarnessCodex = "codex" HarnessFake = "fake" )
Harness ids, referenced by the Supported maps below. The harness package owns the Harness implementations; these constants are the shared vocabulary so the registry can name executors without importing that package.
const ( // DefaultAlias is the default stage model (the analysis and the fallback // remediation model). DefaultAlias = "anthropic/claude-sonnet" // DefaultAllowlist is the default remediation model allowlist. DefaultAllowlist = "anthropic/claude-sonnet,anthropic/claude-opus" )
Shipped default model ids (the controllers' flag defaults and the pod-side fallback). Family aliases track the newest registered version.
Variables ¶
var KnownHarnessIDs = []string{HarnessClaude, HarnessCodex, HarnessFake}
KnownHarnessIDs is the set of harness ids the registry may name in a Supported map, in registry order. That order is the deterministic tiebreak for harness resolution when a model's preferred harness is not enabled.
Functions ¶
func Canonicalize ¶ added in v0.14.0
Canonicalize maps every id to the concrete canonical id it resolves to against the builtins (aliases become the newest registered version), trims blanks, and drops duplicates while keeping first-seen order. It errors on an alias of an unknown family and on an id that is neither registered nor a well-formed Anthropic version id.
func Concrete ¶ added in v0.14.0
Concrete maps id to the concrete canonical id it resolves to against the builtins, or returns it unchanged when it does not resolve. It is the lenient form of Canonicalize for places that must not fail (pod-side defaults); controllers validate with Canonicalize at startup.
func IsAlias ¶ added in v0.14.0
IsAlias reports whether id is a family alias (anthropic/claude-<family>): a name for "the newest registered version of this family" rather than a concrete model.
func IsKnownHarnessID ¶
IsKnownHarnessID reports whether id names a harness the registry knows.
func IsProviderID ¶
IsProviderID reports whether id names a known vendor.
func ParseClaudeID ¶ added in v0.14.0
ParseClaudeID parses a vendor-bare Anthropic model id of the form claude-<family>-<major>[-<minor>]. A missing minor is 0. Dated, version-first or otherwise unrecognised ids return ok=false.
func Synthesized ¶ added in v0.14.0
Synthesized reports whether m was synthesized by the pattern tier rather than registered: it runs on the claude harness only and carries no pricing.
func UsageCostUSD ¶
func UsageCostUSD(m Model, inputTokens, cacheReadTokens, cacheCreationTokens, outputTokens int) *float64
UsageCostUSD prices a measured token usage at the model's rates, or nil when the model has no published pricing. It is the fallback for a harness that reports no cost of its own, so it prices every input-side count rather than just the fresh tokens.
Cache reads bill at CachedInputUSD, roughly a tenth of the base rate, which is where the bulk of a long agent session's input lands. Cache writes bill at the base input rate: OpenAI does not price them separately, and while Anthropic charges a 1.25x premium on a 5m write, the claude CLI reports a cost of its own, so that path only ever cross-checks a figure the harness already gave us.
Types ¶
type Model ¶
type Model struct {
ID string `json:"id"`
ProviderID string `json:"provider_id"`
Name string `json:"name"`
InputUSD *float64 `json:"input_per_mtok"`
CachedInputUSD *float64 `json:"cached_input_per_mtok"`
OutputUSD *float64 `json:"output_per_mtok"`
Supported map[string]string `json:"supported"`
Preferred string `json:"preferred"`
// contains filtered or unexported fields
}
Model is one canonical, vendor-owned model. ID is provider-qualified ("anthropic/claude-sonnet-5") and is the stable id patchy stores in config, the investigation report, and the CRDs; the executing harness never appears in it.
Supported maps each harness id that can run this model to the CLI-specific model-id string that harness's --model flag expects. Any harness/vendor id divergence lives here. Preferred is the harness chosen when several supported harnesses are enabled; it is always a key of Supported.
InputUSD/OutputUSD are USD per 1M tokens (standard tier, cache-miss rates); nil means the vendor has not published per-token pricing. They exist so a harness that reports token usage but not cost (codex) can still be priced. CachedInputUSD is the cache-read (cache-hit) rate, an order of magnitude below InputUSD on both vendors; nil falls back to InputUSD.
func AllModels ¶
AllModels returns the canonical model registry with any per-provider config override applied. overrides maps a provider id to a replacement model list (replace, not merge: partial merges make it unclear which price won); only models whose ProviderID is overridden are replaced.
func Builtins ¶
func Builtins() []Model
Builtins returns the canonical model registry (no overrides). It is the default set patchy resolves models against.
func Lookup ¶ added in v0.14.0
Lookup resolves id against the builtin registry: Resolve(Builtins(), id).
func ModelByID ¶
ModelByID returns the model with exactly the given canonical id from models, if any. It does no alias or pattern resolution; consumers validating a configured or reported id use Resolve / Lookup instead.
func Resolve ¶ added in v0.14.0
Resolve looks id up in models in three tiers, returning the first hit:
- exact: a registered model with that canonical id;
- alias: anthropic/claude-<family> resolves to the highest (major, minor) registered Anthropic model of that family, or ok=false when the family has no registered model;
- pattern: a well-formed anthropic/claude-<family>-<major>[-<minor>] with no registry entry is synthesized as a claude-harness-only, unpriced model (see Synthesized), so an Anthropic release patchy has not registered yet still runs.
It is the one lookup every consumer validating a configured or reported model id uses.
func WithResolved ¶ added in v0.14.0
WithResolved returns models plus a synthesized entry for every id that resolves only through the pattern tier, so code that iterates a model list (provider.EffectiveModelMap deriving Bedrock/Vertex ids) covers those too. models itself is not modified.
func (Model) BareID ¶
BareID is the id without its provider prefix ("claude-sonnet-5"): the vendor's own model id, independent of the executing harness.
func (Model) CLIModelID ¶
CLIModelID returns the harness-specific model-id string this model's --model flag expects for harnessID, and whether the harness supports it.
func (Model) SupportedHarnessIDs ¶
SupportedHarnessIDs lists the harness ids that can run this model, sorted for stable display.
type Provider ¶
type Provider struct {
ID string `json:"id"` // registry key, e.g. "anthropic"
Name string `json:"name"` // human name, e.g. "Anthropic"
}
Provider is a model vendor: the entity that owns and prices a family of models (Anthropic, OpenAI). It is distinct from a harness (the CLI that drives a model) because several harnesses can in principle run one vendor's model, and the vendor id keys pricing while the harness id keys execution.
func ProviderByID ¶
ProviderByID returns the vendor with the given id, if any.