Versions in this module Expand all Collapse all v1 v1.0.0 Nov 24, 2026 Changes in this version + var ErrDeferred = errors.New("tool call awaits approval") + var ErrLimit = errors.New("run limit reached") + var ErrRetries = errors.New("model correction limit reached") + func AccountModelRequest(ctx context.Context, op func(context.Context) (Usage, error)) error + func BindState[T any](r *Run, name string, state *T) error + func Retry(err error) error + type Agent struct + Capabilities []Capability + Instructions string + Limits Limits + MaxRetries int + Model Model + Output Output[T] + func (a Agent[T]) Advance(ctx context.Context, s Snapshot, opts Options) (Result[T], error) + func (a Agent[T]) Resume(ctx context.Context, s Snapshot, opts Options) (Result[T], error) + func (a Agent[T]) Run(ctx context.Context, prompt string, opts Options) (Result[T], error) + type Call struct + Arguments string + ID string + Name string + type Capability func(context.Context, *Run) error + func Combine(caps ...Capability) Capability + func ToolBridge(wrapped ...Capability) Capability + func Tools(tools ...Tool) Capability + type Decision uint8 + const Approve + const Defer + const Deny + type Definition struct + Description string + Name string + Schema json.RawMessage + type Event struct + Call Call + Delegates []string + Kind string + Text string + Usage Usage + type Image struct + Data []byte + MediaType string + URL string + func (i Image) Validate() error + type Limits struct + InputTokens int + OutputTokens int + Requests int + ToolCalls int + TotalTokens int + type Message struct + CallID string + Calls []Call + ContextKind string + ContextTokens int + Images []Image + Model string + Native *NativeContext + Pinned bool + Reasoning []ReasoningItem + Role Role + Text string + type Model interface + Generate func(context.Context, Request) (Response, error) + type ModelFunc func(context.Context, Request) (Response, error) + func (f ModelFunc) Generate(ctx context.Context, q Request) (Response, error) + type NamedModel interface + ModelName func() string + type NativeContext struct + Boundary bool + Content string + Encrypted string + Endpoint string + ID string + Signature string + Tokens int + Transport string + type Options struct + Authorize func(context.Context, Call) (Decision, error) + Checkpoint func(context.Context, Snapshot) error + History []Message + Images []Image + Observe func(context.Context, Event) error + type Output struct + Decode func(string) (T, error) + Schema json.RawMessage + func JSON[T any]() Output[T] + func Text() Output[string] + type ReasoningItem struct + BeforeCall int + Encrypted string + Endpoint string + ID string + Summary json.RawMessage + type Request struct + Messages []Message + OutputSchema json.RawMessage + Tools []Definition + type Response struct + CacheReadTokens int + CacheWriteTokens int + Calls []Call + ContextTokens int + InputTokens int + Model string + Native *NativeContext + OutputTokens int + Reasoning []ReasoningItem + Text string + type Result struct + Output T + type Role string + const Assistant + const System + const ToolResult + const User + type Run struct + AfterResponse []func(context.Context, Response) error + AroundTool []ToolMiddleware + Authorize func(context.Context, Call) (Decision, error) + BeforeRequest []func(context.Context, *Request, Usage) error + CheckDelta []func(context.Context, string) error + CheckOutput []func(context.Context, string) error + FirstRequest bool + Instructions []string + Limits Limits + Model Model + OnClose []func() error + PrepareCall []func(Call) (Call, error) + Prompt string + ReviewOutput []func(context.Context, string) (string, error) + RewriteHistory []func(context.Context, Request, Usage) ([]Message, error) + Step int + TransformText []func(context.Context, string) (string, error) + func (r *Run) ChildOptions(ctx context.Context, name string, shareUsage, forwardEvents bool) (Options, error) + func (r *Run) EditAnsweredToolResult(ctx context.Context, id string, edit func(Call, string) (string, error)) error + func (r *Run) FilterPrompt(f func(string) (string, error)) error + func (r *Run) InvokeTool(ctx context.Context, t Tool, c Call) (string, error) + func (r *Run) Register(tools ...Tool) error + func (r *Run) SelfAgent() Agent[string] + type Snapshot struct + AwaitingApproval bool + Complete bool + Correction string + History []Message + Offered []string + Pending []Call + Prompt string + PromptFiltered bool + RequestStep int + Retries int + State map[string]json.RawMessage + Usage Usage + func Start(prompt string, previous []Message, images ...Image) Snapshot + type StreamingModel interface + Stream func(context.Context, Request, func(string) error) (Response, error) + type Tool struct + Execute func(context.Context, Call) (string, error) + TextResult bool + func NewTool[I, O any](name, description string, fn func(context.Context, I) (O, error)) Tool + type ToolHandler func(context.Context, Call) (string, error) + type ToolMiddleware func(ToolHandler) ToolHandler + type Usage struct + InputTokens int + OutputTokens int + Requests int + ToolCalls int