models

package
v2.7.0-dev.5 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package models is the adapter layer between core-agent's configuration and concrete LLM backends. The Provider interface keeps the rest of the codebase free of provider-specific imports so additional backends plug in behind the same contract.

Built-in providers:

  • "gemini" / "vertex" — google.golang.org/adk/model/gemini
  • "anthropic" — Claude via github.com/anthropics/anthropic-sdk-go

Each backend's package init() calls Register so importing the subpackage is enough to make the provider available.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoDetectProvider

func AutoDetectProvider() string

AutoDetectProvider walks the env to pick a default backend. Exported alias of autoDetectProvider for callers that need the provider name BEFORE constructing a Provider (e.g. cmd/core-agent's --task flag resolution needs the provider name to pick a model for a given tier without paying for full provider construction).

Returns "" when no env-based default is detectable. Returns the same canonical name strings as Resolve would route to.

func Register

func Register(name string, c Constructor)

Register installs a Constructor under its provider name. Idiomatically called from package init() in each backend implementation.

func ResolveMCPSmallModel

func ResolveMCPSmallModel(p Provider, mcpSpecific, agenticGeneral string) string

ResolveMCPSmallModel is ResolveSmallModel's MCP-wrap sibling — layers a per-surface override (mcp.json's agentic_wrap_model or --mcp-agentic-wrap-model) in front of the general chain so operators can pick a different tier for MCP responses than for built-in-tool wrappers. Rationale: MCP responses can be shaped differently enough (structured GKE tables vs. arbitrary fetch_url bodies) that one tier works well for one surface but not the other.

Precedence: mcpSpecific → agenticGeneral → provider default → "".

func ResolveSmallModel

func ResolveSmallModel(p Provider, override string) string

ResolveSmallModel picks the model ID that agentic subtasks should run on. Operator override (a non-empty explicit --agentic-small-model value) always wins. Otherwise: if p implements SmallModelDefaulter, return whatever it reports; if not, return "" — agentic wrappers treat empty as "inherit the parent's model."

Types

type Constructor

type Constructor func(*config.Config) (Provider, error)

Constructor builds a Provider from validated config. Tests register alternates via Register so resolution stays decoupled from the imports of any single backend.

type Provider

type Provider interface {
	// Name reports the provider identity ("gemini", "vertex", "anthropic").
	// Used for telemetry and diagnostic messages.
	Name() string

	// Model returns a usable model.LLM for the given model ID. The same
	// Provider may be asked for several models over its lifetime.
	Model(ctx context.Context, modelID string) (model.LLM, error)
}

Provider constructs concrete model.LLM instances on demand. A Provider is bound to one credential source (API key, Vertex project, etc.) at construction time; callers ask for specific models by ID through Model.

func Resolve

func Resolve(cfg *config.Config) (Provider, error)

Resolve picks the right Provider for cfg, honoring (in order): explicit cfg.Model.Provider, then env-based auto-detection. Returns a clear error when no path is viable so the user knows which env var or config field to set.

type SmallModelDefaulter

type SmallModelDefaulter interface {
	DefaultSmallModel() string
}

SmallModelDefaulter is an optional Provider extension. A Provider that implements this declares its preferred cheap-tier model — used by core-agent as the default for --agentic-small-model when the operator hasn't pinned one explicitly. Providers without a cheap-tier concept (echo, scripted) simply don't implement this; ResolveSmallModel returns "" for them and callers fall back to inheriting the parent's model.

Directories

Path Synopsis
Package anthropic implements models.Provider for Anthropic / Claude.
Package anthropic implements models.Provider for Anthropic / Claude.
Package gemini implements models.Provider for the Gemini family, covering both the public Gemini API (API-key auth) and Vertex AI (Application Default Credentials + GCP project).
Package gemini implements models.Provider for the Gemini family, covering both the public Gemini API (API-key auth) and Vertex AI (Application Default Credentials + GCP project).
Package mock ships two credential-free LLM providers and a recording wrapper that pair for offline testing of agent flows:
Package mock ships two credential-free LLM providers and a recording wrapper that pair for offline testing of agent flows:

Jump to

Keyboard shortcuts

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