Documentation
¶
Overview ¶
Package provider is the one place the environment is mapped onto an LLM backend. Both `whetstone` (authoring, on a developer's machine) and `skael-worker` (scoring, on a server) resolve their gateway here, so a misconfiguration is diagnosed with the same words wherever it is met.
Four provider modes, and no variable outside this file selects one:
- Anthropic direct ANTHROPIC_API_KEY
- Compatible gateway ANTHROPIC_BASE_URL + ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN
- Subscription CLI nothing set, and an agent CLI on PATH
- Split mode 2, plus CLAUDE_CODE_OAUTH_TOKEN
The judge and the eval panel share ANTHROPIC_BASE_URL. They did not always: the judge had LLM_BASE_URL of its own, which meant one gateway could be configured while the other silently kept dialling Anthropic. Two names for one endpoint bought nothing that two values of one name does not.
Mode 4 is the one case where they separate, and it is selected by a combination of names that already existed rather than by a new one. Setting CLAUDE_CODE_OAUTH_TOKEN alongside a gateway states a subscription for the panel; the judge keeps the gateway, because a published score must come from a metered, reproducible backend. The mode is not free: the panel is recorded in model_panel, so turning it on splits a skill's score trend at the changeover. See PanelModels and PanelExcludeEnv.
Index ¶
Constants ¶
const ( APIKeyEnv = "ANTHROPIC_API_KEY" AuthTokenEnv = "ANTHROPIC_AUTH_TOKEN" BaseURLEnv = "ANTHROPIC_BASE_URL" // ModelEnv is a comma-separated list, most capable first. The first entry // serves every judge call and the panel's primary member; the rest are the // panel's floor members, which only the deep tier runs. It replaces the // former LLM_STRONG_MODEL/LLM_FAST_MODEL pair, whose two names could be // half-set — a panel with one working member and one that 404s is not an // error but a complete run that scores and can never release anything. ModelEnv = "LLM_MODEL" // OAuthTokenEnv is Claude Code's own subscription credential. It is read // here only to select mode 4 — this package never authenticates a judge // call with it, because a subscription is neither metered nor pinned to a // model, and a released version's score must be both. OAuthTokenEnv = "CLAUDE_CODE_OAUTH_TOKEN" )
The environment this package reads. These are the Anthropic SDK's and the Claude Code CLI's own names rather than Skael-specific ones, so a machine already set up for either needs no further configuration — and so the panel, which is a Claude Code CLI running inside a sandbox, reads the same values the worker resolved.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Kind Kind
// Detail explains the choice in one clause, including why it is none.
Detail string
// Binary is the agent CLI backing a subscription provider.
Binary string
// BaseURL is ANTHROPIC_BASE_URL, empty for Anthropic's own API. It is the
// panel's gateway as much as the judge's.
BaseURL string
// Key is whichever credential authenticates the API provider.
Key string
// AuthStyle is inferred from which credential was set rather than
// configured: a bearer token is only ever presented as a bearer token.
AuthStyle api.AuthStyle
// Models is ModelEnv, split and trimmed. Empty means the shipped defaults.
Models []string
// PanelSubscription reports mode 4: the judge dials BaseURL, and the eval
// panel authenticates with OAuthTokenEnv instead. It changes what the
// panel asks for (PanelModels) and what the sandbox is allowed to see
// (PanelExcludeEnv); both are required, because either one alone leaves
// the panel on the gateway.
PanelSubscription bool
}
Config is the resolved provider. It is data only: nothing here dials anything until Gateway is called.
func APIFromEnv ¶
func APIFromEnv() Config
APIFromEnv is FromEnv with subscription detection off, for a caller whose backend must be metered and reproducible — `skael-worker`, whose judge output releases versions. A CLI on the worker's host is then not a provider at all rather than a provider it must refuse, so an operator who has both a key and a CLI installed is served by the key.
func FromEnv ¶
func FromEnv() Config
FromEnv resolves the provider from this process's environment, including a subscription CLI on PATH.
func Resolve ¶
Resolve picks a provider.
Explicit gateway configuration beats autodetection: setting a base URL or a bearer token is an unambiguous statement that a particular gateway is intended, and silently preferring a subscription CLI that happens to be on PATH would bill the wrong account and evaluate against a different model than the one configured.
APIKeyEnv alone stays *below* the CLI. It is present on plenty of developer machines that also have the CLI installed, and treating it as an override would move those machines onto metered billing without anyone asking for it.
func (Config) PanelExcludeEnv ¶
PanelExcludeEnv names the credential variables a sandbox must NOT be given, even though the agent adapter declares them. It is empty in every mode but the split.
This is the half that actually moves the panel. The claude-code adapter forwards each name it declares that is set, so a worker whose own environment names a gateway hands that gateway to every panel member. PanelModels alone does not help: the member would ask a subscription for the alias it serves and still be pointed at the gateway to ask.
The API key is withheld with the gateway's own two names. It is not the judge's credential in this mode, and forwarding it leaves the sandbox holding two competing credentials, which is the ambiguity this mode exists to remove.
func (Config) PanelModels ¶
PanelModels is the model ids the eval panel should ask for, empty when the shipped default is right.
Gated on BaseURL, not on ModelEnv alone: an operator who named a model to pick a cheaper judge against Anthropic's own API must keep the panel they had, since a changed panel is recorded in model_panel and splits the score trend. A custom gateway is the case where the shipped aliases cannot work. A panel on the subscription is the other empty case: a subscription serves Anthropic's own aliases, so handing it the gateway's namespaced ids fails every member's health probe — a complete run that scores nothing and can never release the version it was meant to clear.
type Getenv ¶
Getenv is os.Getenv, injectable so resolution is testable without touching the process environment.