agents

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package agents loads the agents a workspace offers: the built-in ones and Markdown files with YAML frontmatter from ~/.blitz/agents (and the project's, when it's trusted), each a name, a description, a system prompt, the tools it may use and optionally its own model (spec_agents_014).

Index

Constants

This section is empty.

Variables

View Source
var AgencyLevels = []string{"low", "medium", "high", "extreme"}

AgencyLevels are the agency levels an agent may declare.

Functions

func Delete

func Delete(dir, name string) error

Delete removes the file in dir that defines name.

func DeleteFile

func DeleteFile(dir, path string) error

DeleteFile removes path, an agent file in dir (or below it), whether or not it parses.

func Save

func Save(dir string, spec *AgentSpec, previous string, builtin func(string) bool) (path string, problems []string, err error)

Save writes spec to its file in dir: in place of previous's file when previous names one (a rename, or "" for a new agent), else dir/<name>.md. What's wrong with spec comes back as problems, with nothing written.

func ValidName

func ValidName(name string) bool

ValidName reports whether name can name an agent the editors write: lowercase letters, digits, - and _, starting with a letter or digit.

Types

type AgentMetadata

type AgentMetadata struct {
	Name         string   `yaml:"name"`
	DisplayName  string   `yaml:"display_name,omitempty"`
	Description  string   `yaml:"description"`
	Tools        []string `yaml:"tools"`
	DefaultModel string   `yaml:"default_model,omitempty"`
	AgencyLevel  string   `yaml:"agency_level,omitempty"`
	// PermissionMode is the mode it runs in through invoke_agent: default,
	// plan, accept-edits, dont-ask or bypass ("": the workspace's). A
	// project's agent may only tighten until the project is trusted, and
	// bypass needs the OS sandbox.
	PermissionMode string `yaml:"permission_mode,omitempty"`
	// MaxTurns caps its model calls through invoke_agent (0: the caller's
	// budget, or a background task's).
	MaxTurns int `yaml:"max_turns,omitempty"`
	// Background makes invoke_agent run it in the background unless the
	// call says otherwise.
	Background bool `yaml:"background,omitempty"`
	// Isolation "worktree" runs it, in the background, in its own git
	// worktree and branch.
	Isolation string `yaml:"isolation,omitempty"`

	// The model settings it runs with, over the model's own
	// ([model_settings]) and the session's effort; unset leaves those.
	Temperature    *float64 `yaml:"temperature,omitempty"`
	TopP           *float64 `yaml:"top_p,omitempty"`
	MaxTokens      *int     `yaml:"max_tokens,omitempty"`
	Effort         string   `yaml:"effort,omitempty"`
	ThinkingBudget *int     `yaml:"thinking_budget,omitempty"`
}

AgentMetadata holds frontmatter metadata defined in the markdown header.

func (AgentMetadata) Check

func (m AgentMetadata) Check() error

Check returns what keeps the metadata from loading, or nil.

func (AgentMetadata) ModelSettings

func (m AgentMetadata) ModelSettings() (config.ModelSettings, bool)

ModelSettings returns the model settings the agent sets, and whether it sets any.

type AgentSpec

type AgentSpec struct {
	AgentMetadata
	SystemPrompt string
	// Path is the file it came from ("" for a built-in agent).
	Path string
}

AgentSpec represents a parsed agent specification with frontmatter and markdown body.

func ParseMarkdownSpec

func ParseMarkdownSpec(content []byte) (*AgentSpec, error)

ParseMarkdownSpec parses a markdown file containing YAML frontmatter.

func (*AgentSpec) InterpolatePrompt

func (spec *AgentSpec) InterpolatePrompt(agencyLevel string) string

InterpolatePrompt fills in the agency rules for agencyLevel ("" is high).

func (*AgentSpec) Marshal

func (spec *AgentSpec) Marshal() ([]byte, error)

Marshal writes spec as an agent file: its frontmatter, then its prompt.

type File

type File struct {
	Path string
	// Spec is what it defines; nil when it doesn't parse.
	Spec *AgentSpec
	// Problem is why it doesn't load ("" when it does).
	Problem string
}

File is one agent file in a folder.

func ListFiles

func ListFiles(dir string, builtin func(string) bool) ([]File, error)

ListFiles returns the agent files in dir (a leading "~" is expanded) and below it, by path; a folder that doesn't exist has none. builtin names the built-in agents, which a file can't redefine.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages discovered and built-in agents.

func NewRegistry

func NewRegistry() (*Registry, error)

NewRegistry creates a new Registry and loads built-in embedded agent specs.

func (*Registry) Get

func (r *Registry) Get(name string) (*AgentSpec, bool)

Get retrieves an agent spec by name.

func (*Registry) IsBuiltin

func (r *Registry) IsBuiltin(name string) bool

IsBuiltin reports whether name is a built-in agent's.

func (*Registry) List

func (r *Registry) List() []*AgentSpec

List returns all registered agents sorted by name.

func (*Registry) LoadExternalAgents

func (r *Registry) LoadExternalAgents(dirs ...string) error

LoadExternalAgents scans directories for user-defined .md agent specifications. A leading "~" is expanded. External specs may add new agents but may not replace built-in ones, since that would let a directory silently swap the system prompt and tool list of a trusted persona. Rejected or unparsable specs are reported in the returned (joined) error; valid ones are still loaded. The directories are remembered for Refresh.

func (*Registry) Refresh

func (r *Registry) Refresh() (bool, error)

Refresh loads the external agents again if a file in their directories was added, changed or removed since they were last loaded, and reports whether it did. An agent whose file is gone is gone.

Directories

Path Synopsis
Package builtin holds the agents Blitz ships with, as Markdown files embedded in the binary.
Package builtin holds the agents Blitz ships with, as Markdown files embedded in the binary.

Jump to

Keyboard shortcuts

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