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

agent

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package agent provides tool definitions for the autonomous agentic verification loop used during code generation. Tools include sandboxed file I/O (read, write, list), Go toolchain operations (build, test, get, mod tidy), and linting — all scoped to a project root directory for safety.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBuildFailed        = errors.NewSentinel("gtb.agent.build_failed", "build failed")
	ErrTestFailed         = errors.NewSentinel("gtb.agent.test_failed", "tests failed")
	ErrGoGetFailed        = errors.NewSentinel("gtb.agent.go_get_failed", "go get failed")
	ErrLinterFailed       = errors.NewSentinel("gtb.agent.linter_failed", "lint issues found")
	ErrGoModTidyFailed    = errors.NewSentinel("gtb.agent.go_mod_tidy_failed", "go mod tidy failed")
	ErrPathInvalid        = errors.NewSentinel("gtb.agent.path_invalid", "path is outside of allowed directory")
	ErrInvalidPackageName = errors.NewSentinel("gtb.agent.invalid_package_name", "invalid package name")
)
View Source
var ErrQueryQuestionRequired = errors.NewSentinel("gtb.agent.query_question_required", "query_user requires a question")

ErrQueryQuestionRequired is returned when the model calls query_user without a question.

Functions

func GoBuildTool

func GoBuildTool(afs afero.Fs, basePath string) gochat.Tool

GoBuildTool returns a tool for running 'go build ./...'.

func GoGetTool

func GoGetTool(afs afero.Fs, basePath string) gochat.Tool

GoGetTool returns a tool for running 'go get'.

func GoModTidyTool

func GoModTidyTool(afs afero.Fs, basePath string) gochat.Tool

GoModTidyTool returns a tool for running 'go mod tidy'.

func GoTestTool

func GoTestTool(afs afero.Fs, basePath string) gochat.Tool

GoTestTool returns a tool for running 'go test ./...'.

func LinterTool

func LinterTool(afs afero.Fs, basePath string) gochat.Tool

LinterTool returns a tool for running 'golangci-lint run --fix'.

func ListDirTool

func ListDirTool(afs afero.Fs, basePath string) gochat.Tool

ListDirTool returns a tool for listing directory contents.

func QueryUserTool

func QueryUserTool(prompter UserPrompter) gochat.Tool

QueryUserTool returns a tool that lets the model ask the human a clarifying question rather than guess. It is only registered for interactive runs; the prompter performs the actual interaction.

func ReadFileTool

func ReadFileTool(afs afero.Fs, basePath string) gochat.Tool

ReadFileTool returns a tool for reading file content.

func ReadFilesTool

func ReadFilesTool(afs afero.Fs, basePath string) gochat.Tool

ReadFilesTool returns a tool for reading several files in a single call, so the agent doesn't spend a round-trip per file. Each file's content is returned under a header; a path that can't be read is reported inline rather than failing the whole batch.

func TreeTool

func TreeTool(afs afero.Fs, basePath string) gochat.Tool

TreeTool returns a tool that lists a directory and all its subdirectories recursively in a single call, as sorted relative paths. It saves the agent from walking the layout one folder at a time with list_dir.

func WriteFileTool

func WriteFileTool(afs afero.Fs, basePath string) gochat.Tool

WriteFileTool returns a tool for writing content to a file.

Types

type UserPrompter

type UserPrompter func(ctx context.Context, question string, suggestions []string) (string, error)

UserPrompter asks the user a question, offering the model's suggested answers, and returns the reply (a chosen suggestion or free text). It backs the query_user tool; the caller supplies an interactive implementation and omits the tool entirely in non-interactive runs.

Jump to

Keyboard shortcuts

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