Help us shape the future of Go! Take the 2026 Go Developer Survey

agent

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package agent resolves provider configuration into a weft.Model and assembles the hmm agent: name, system prompt, core tools, loop policy. The agent is a value built per invocation; nothing here talks to the network.

Index

Constants

View Source
const (
	ProviderAnthropic = "anthropic"
	ProviderOpenAI    = "openai"
	ProviderGoogle    = "google"
	ProviderZai       = "zai"
	ProviderKimi      = "kimi"
)

Provider names accepted by --provider / HMM_PROVIDER. The three first-party adapters plus zai and kimi: z.ai's GLM and Moonshot's Kimi, both over their OpenAI-compatible endpoints (weft's openai adapter, BaseURL + key).

View Source
const DefaultProvider = ProviderAnthropic

DefaultProvider is what runs when nothing else is configured.

Variables

This section is empty.

Functions

func Build

func Build(m weft.Model, cfg Config, lib *plugins.Library) *weft.Agent

Build assembles the agent value: name, instructions, core tools, and loop policy. With a Library, the plugin-admin tools join the static set and weft.ToolSource refreshes the advertised tools each step — a plugin installed mid-run is callable by name in the next step (weft's RawTool/ToolSource seams).

func EnvKey

func EnvKey(provider string) string

EnvKey returns the provider's key from the environment, following each provider's own conventions (plus hmm's HMM_* names for the gateway providers; the pre-rename BOBINA_* names still work). Empty when unset.

func Instructions

func Instructions(extra string) string

Instructions is the hmm system prompt — a contract the model sees; changes are deliberate and pinned by tests. extra (--system) is appended verbatim.

func NewModel

func NewModel(c Config) (weft.Model, error)

NewModel resolves Config into a weft.Model. Provider keys follow the adapters' own env conventions; zai and kimi add their own (HMM_ZAI_KEY or ZAI_API_KEY; HMM_KIMI_KEY, KIMI_API_KEY, or MOONSHOT_API_KEY). A missing key is an early, named error.

func StaticToolNames

func StaticToolNames() []string

StaticToolNames lists the built-in tool names (core + plugin admin) in build order. The CLI reserves them on the library before its startup scan, so a plugin already on disk can never shadow one — providers reject duplicate advertised tool names.

Types

type Config

type Config struct {
	Provider     string
	Model        string
	SystemAppend string // --system: appended to the default prompt
	MaxSteps     int    // 0 keeps weft's default
	Sequential   bool
	Yolo         bool
	Confirm      func(question string) bool // TTY y/N gate (run_command, install_plugin)
	// APIKey is the resolved provider key: env by default (EnvKey),
	// overridable from the config file. Empty means "not configured".
	APIKey string
}

Config is the resolved agent configuration (flags over env, done by the CLI before it reaches here).

func (Config) ModelInfo

func (c Config) ModelInfo() (provider, model string, err error)

ModelInfo reports the provider and model name that a Config resolves to, for the session header — without constructing the model.

Jump to

Keyboard shortcuts

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