Versions in this module Expand all Collapse all v0 v0.1.1 Jul 21, 2026 Changes in this version + type Compactor interface + Compact func(ctx context.Context, msgs []Message) ([]Message, error) + func NewWindowCompactor(maxMessages int) Compactor type Option + func WithCompactor(c Compactor, thresholdTokens int) Option v0.1.0 Jul 20, 2026 v0.0.2 Jul 20, 2026 v0.0.1 Jul 20, 2026 Changes in this version + const DefaultMaxIterations + func IsRetryable(err error) bool + type Agent struct + func New(opts ...Option) *Agent + func (a *Agent) NewSession(id string) *Session + func (a *Agent) Note(_ context.Context, note string) (Message, error) + func (a *Agent) Run(ctx context.Context, input string) (*Result, error) + func (a *Agent) RunMessages(ctx context.Context, msgs ...Message) (*Result, error) + func (a *Agent) RunMessagesStream(ctx context.Context, msgs ...Message) (EventStream, error) + func (a *Agent) RunStream(ctx context.Context, input string) (EventStream, error) + type Capabilities struct + Documents bool + MaxContextTokens int + MaxOutputTokens int + MidConversationSystem bool + ParallelToolCalls bool + Streaming bool + SystemCaching bool + Thinking bool + Tools bool + Vision bool + func CapabilitiesOf(p Provider) Capabilities + type Capable interface + Capabilities func() Capabilities + type ContentBlock interface + type ConversationStore interface + Load func(ctx context.Context, sessionID string) ([]Message, error) + Save func(ctx context.Context, sessionID string, msgs []Message) error + func NewInMemoryStore() ConversationStore + type DocumentBlock struct + Source ImageSource + Title string + type Error struct + Cause error + Code ErrorCode + Message string + Provider string + RetryAfter time.Duration + Retryable bool + func (e *Error) Error() string + func (e *Error) Unwrap() error + type ErrorCode string + const ErrAuthentication + const ErrContextExceeded + const ErrInvalidRequest + const ErrMaxIterations + const ErrNotFound + const ErrOverloaded + const ErrPermission + const ErrProviderInternal + const ErrRateLimited + const ErrRefusal + const ErrStreamUnsupported + const ErrUnknown + func CodeOf(err error) ErrorCode + type Event struct + Response *Response + Result *Result + TextDelta string + ThinkingDelta string + ToolCall *ToolCall + ToolResult *ToolResult + Type EventType + type EventStream interface + Close func() error + Next func(ctx context.Context) (Event, error) + func NewSliceStream(events ...Event) EventStream + type EventType string + const EventMessageDone + const EventRunDone + const EventTextDelta + const EventThinkingDelta + const EventToolCallDelta + const EventToolCallEnd + const EventToolCallStart + const EventToolResult + type Hooks struct + AfterGenerate func(ctx context.Context, resp *Response) + AfterToolCall func(ctx context.Context, call ToolCall, result ToolResult) + BeforeGenerate func(ctx context.Context, req *Request) error + BeforeToolCall func(ctx context.Context, call ToolCall) (allow bool, override *ToolResult) + OnError func(ctx context.Context, err error) + type ImageBlock struct + Source ImageSource + type ImageSource struct + Data string + Kind SourceKind + MediaType string + type Message struct + Content []ContentBlock + Role Role + func AssistantMessage(blocks ...ContentBlock) Message + func UserMessage(text string) Message + func UserMessageBlocks(blocks ...ContentBlock) Message + func (m Message) Text() string + func (m Message) ToolUses() []ToolUseBlock + type Option func(*Agent) + func WithConversationStore(s ConversationStore) Option + func WithHooks(h Hooks) Option + func WithMaxIterations(n int) Option + func WithMaxParallelTools(n int) Option + func WithMaxTokens(n int) Option + func WithModel(model string) Option + func WithProvider(p Provider) Option + func WithRetryPolicy(rp RetryPolicy) Option + func WithStreamingFallback(mode StreamingFallbackMode) Option + func WithSystemPrompt(sp *SystemPrompt) Option + func WithThinking(cfg ThinkingConfig) Option + func WithToolChoice(tc ToolChoice) Option + func WithTools(tools ...RegisteredTool) Option + type Provider interface + Generate func(ctx context.Context, req *Request) (*Response, error) + Name func() string + type RegisteredTool interface + Description func() string + Invoke func(ctx context.Context, input json.RawMessage) (ToolResult, error) + Name func() string + Schema func() *schema.Schema + type Request struct + MaxTokens int + Messages []Message + Metadata map[string]string + Model string + System []SystemBlock + Thinking *ThinkingConfig + ToolChoice ToolChoice + Tools []RegisteredTool + type Response struct + ID string + Message Message + Model string + Raw any + StopReason StopReason + Usage Usage + type Result struct + FinalResponse *Response + Iterations int + Messages []Message + Usage Usage + type RetryPolicy struct + BaseDelay time.Duration + Jitter bool + MaxDelay time.Duration + MaxRetries int + func DefaultRetryPolicy() RetryPolicy + type Role string + const RoleAssistant + const RoleUser + type Session struct + func (s *Session) History(ctx context.Context) ([]Message, error) + func (s *Session) ID() string + func (s *Session) Reset(ctx context.Context) error + func (s *Session) Send(ctx context.Context, input string) (*Result, error) + type SourceKind string + const SourceBase64 + const SourceURL + type StopReason string + const StopContentFilter + const StopEndTurn + const StopMaxTokens + const StopRefusal + const StopToolUse + const StopUnknown + type StreamingFallbackMode string + const FallbackError + const FallbackSingleShot + type StreamingProvider interface + Stream func(ctx context.Context, req *Request) (EventStream, error) + type SystemBlock struct + Cacheable bool + Text string + type SystemPrompt struct + func NewSystemPrompt() *SystemPrompt + func (s *SystemPrompt) Add(text string) *SystemPrompt + func (s *SystemPrompt) AddCacheable(text string) *SystemPrompt + func (s *SystemPrompt) AddFunc(fn func(ctx context.Context) (string, error)) *SystemPrompt + func (s *SystemPrompt) AddTemplate(tmpl string, data any) *SystemPrompt + func (s *SystemPrompt) Render(ctx context.Context) ([]SystemBlock, error) + type SystemUpdater interface + SystemUpdateMessage func(note string) (Message, error) + type TextBlock struct + Text string + type ThinkingBlock struct + Signature string + Text string + type ThinkingConfig struct + Budget int + Mode ThinkingMode + type ThinkingMode string + const ThinkingAdaptive + const ThinkingBudgeted + const ThinkingOff + type TokenCounter interface + CountTokens func(ctx context.Context, req *Request) (int, error) + type Tool struct + func NewTool[TIn any](name, description string, ...) *Tool[TIn] + func (t *Tool[TIn]) Description() string + func (t *Tool[TIn]) Invoke(ctx context.Context, raw json.RawMessage) (ToolResult, error) + func (t *Tool[TIn]) Name() string + func (t *Tool[TIn]) Schema() *schema.Schema + type ToolCall struct + ID string + Input json.RawMessage + Name string + type ToolChoice struct + Mode ToolChoiceMode + Name string + type ToolChoiceMode string + const ToolChoiceAny + const ToolChoiceAuto + const ToolChoiceNone + const ToolChoiceOne + type ToolResult struct + Content []ContentBlock + IsError bool + func ErrorResultf(format string, args ...any) ToolResult + func JSONResult(v any) ToolResult + func TextResult(text string) ToolResult + type ToolResultBlock struct + Content []ContentBlock + IsError bool + ToolUseID string + type ToolSet struct + func NewToolSet(tools ...RegisteredTool) *ToolSet + func (ts *ToolSet) Add(t RegisteredTool) *ToolSet + func (ts *ToolSet) Get(name string) (RegisteredTool, bool) + func (ts *ToolSet) List() []RegisteredTool + type ToolUseBlock struct + ID string + Input []byte + Name string + type Usage struct + CacheCreationTokens int + CacheReadTokens int + InputTokens int + OutputTokens int + func (u *Usage) Add(u2 Usage) *Usage