Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMaxIterations = errors.New("max iterations reached") ErrNilModel = errors.New("agent: model is nil") )
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent drives the core loop, invoking middleware, model, and tools.
type Context ¶
type Context struct {
Iteration int
StartedAt time.Time
Values map[string]any
ToolResults []ToolResult
LastModelOutput *ModelOutput
}
Context carries runtime state for a single agent execution.
func NewContext ¶
func NewContext() *Context
type Model ¶
type Model interface {
Generate(ctx context.Context, c *Context) (*ModelOutput, error)
}
Model produces the next output for the agent given the current context.
type ModelOutput ¶
ModelOutput is the result returned by a Model.Generate call.
type Options ¶
type Options struct {
// MaxIterations limits how many cycles Run may execute.
// Zero means no limit.
MaxIterations int
// Timeout bounds the entire Run invocation. Zero disables it.
Timeout time.Duration
// Middleware chain. Defaults to an empty chain when nil.
Middleware *middleware.Chain
}
Options controls runtime behavior of the Agent.
type ToolExecutor ¶
type ToolExecutor interface {
Execute(ctx context.Context, call ToolCall, c *Context) (ToolResult, error)
}
ToolExecutor performs a tool call emitted by the model.
Click to show internal directories.
Click to hide internal directories.