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

agent

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	*Config

	Messages []Message
	Usage    Usage
}

func (*Agent) Models added in v0.6.2

func (a *Agent) Models(ctx context.Context) ([]ModelInfo, error)

Models lists the available models from the API.

func (*Agent) Send

func (a *Agent) Send(ctx context.Context, input []Content) iter.Seq2[Message, error]

type Compaction added in v0.6.2

type Compaction struct {
	ID string `json:"id,omitempty"`

	Signature string `json:"signature,omitempty"`
}

type Config

type Config struct {
	Model           func() string
	Effort          func() string
	Tools           func() []tool.Tool
	Instructions    func() string
	ContextMessages func() []Message

	Hooks hook.Hooks
	// contains filtered or unexported fields
}

func DefaultConfig

func DefaultConfig() (*Config, error)

func (*Config) Derive added in v0.6.2

func (c *Config) Derive() *Config

Derive creates a new Config sharing the same client and model.

type Content

type Content struct {
	Text    string `json:"text,omitempty"`
	Refusal string `json:"refusal,omitempty"`

	File *File `json:"file,omitempty"`

	Reasoning  *Reasoning  `json:"reasoning,omitempty"`
	Compaction *Compaction `json:"compaction,omitempty"`

	ToolCall   *ToolCall   `json:"tool_call,omitempty"`
	ToolResult *ToolResult `json:"tool_result,omitempty"`
}

type File

type File struct {
	Name string `json:"name,omitempty"`
	Data string `json:"data,omitempty"` // base64 data URL, e.g. "data:image/png;base64,..."
}

type Message

type Message struct {
	Role MessageRole `json:"role"`

	Content []Content `json:"content"`
	Hidden  bool      `json:"hidden,omitempty"`
}

type MessageRole

type MessageRole string
const (
	RoleUser      MessageRole = "user"
	RoleAssistant MessageRole = "assistant"
	RoleSystem    MessageRole = "system"
)

type ModelInfo added in v0.6.2

type ModelInfo struct {
	ID string
}

type Reasoning added in v0.6.2

type Reasoning struct {
	ID string `json:"id,omitempty"`

	Text      string `json:"text,omitempty"`
	Summary   string `json:"summary,omitempty"`
	Signature string `json:"signature,omitempty"`
}

type State added in v0.6.2

type State struct {
	Usage    Usage     `json:"usage"`
	Messages []Message `json:"messages,omitempty"`
}

func (*State) Load added in v0.6.2

func (s *State) Load(path string) error

func (*State) Save added in v0.6.2

func (s *State) Save(path string) error

type ToolCall

type ToolCall struct {
	ID string `json:"id"`

	Name string `json:"name"`
	Args string `json:"args,omitempty"`
}

type ToolResult

type ToolResult struct {
	ID string `json:"id,omitempty"`

	Name string `json:"name"`
	Args string `json:"args,omitempty"`

	Content string `json:"content,omitempty"`
}

type Usage

type Usage struct {
	InputTokens  int64 `json:"input_tokens"`
	CachedTokens int64 `json:"cached_tokens"`
	OutputTokens int64 `json:"output_tokens"`
}

Directories

Path Synopsis
ask
fs
lsp
mcp

Jump to

Keyboard shortcuts

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