Versions in this module Expand all Collapse all v1 v1.4.0 Oct 31, 2026 v1.3.0 Oct 30, 2026 v1.2.1 Oct 28, 2026 v1.2.0 Oct 27, 2026 v1.1.0 Oct 27, 2026 Changes in this version type Decision + func (d Decision) String() string + type Settings struct + Approver Approver + Budget func(model.Usage) error + Checkpointer Checkpointer + Instructions string + Limits Limits + Logger *slog.Logger + MaxTokens int + MaxTurns int + Model model.Model + Name string + Output *Output + Parallelism int + ProviderOptions map[string]map[string]any + Reasoning *model.Reasoning + ResponseFormat *model.ResponseFormat + Seed *int + StopAtTools []string + StopWhen []StopCondition + Stream bool + Temperature *float64 + ToolChoice *model.ToolChoice + ToolMiddlewares []tool.Middleware + TopP *float64 v1.0.1 Oct 27, 2026 v1.0.0 Oct 23, 2026 Changes in this version + const DefaultMaxTurns + const DefaultOutputRetries + const HandoffFromKey + const SessionValuePrefix + const StateVersion + var Approve = Approval + var Deny = Approval + var ErrCheckpointNotFound = errors.New("checkpoint not found") + var ErrNoCheckpointer = errors.New("loop: resume requires a checkpointer") + func Block(reason string) error + func CloseToolCalls(msgs []*model.Message, content string) *model.Message + func Deps[T any](ctx context.Context) (T, bool) + func ForwardEvent(ctx context.Context, ev *Event) bool + func InterruptCall(ctx context.Context, intr *Interrupt) bool + func ReportUsage(ctx context.Context, u model.Usage) + func Stop(reason string) error + func WithDeps[T any](ctx context.Context, v T) context.Context + func WithheldAnswer(name string) *model.Message + type AfterModeler interface + AfterModel func(ctx context.Context, run *Run, req *model.Request, resp *model.Response) error + type AfterRunner interface + AfterRun func(ctx context.Context, run *Run, res *Result) + type AfterTooler interface + AfterTool func(ctx context.Context, run *Run, plan *ToolPlan, res *model.ToolResult) error + type AnswerHolder interface + HoldAnswer func() bool + type Approval struct + Approved bool + Reason string + Remember RememberScope + RememberRules []string + UpdatedInput json.RawMessage + type ApprovalRequest struct + Agent string + Call *model.ToolCall + Reason string + type Approver interface + Approve func(ctx context.Context, req *ApprovalRequest) (Approval, error) + type ApproverFunc func(ctx context.Context, req *ApprovalRequest) (Approval, error) + func (f ApproverFunc) Approve(ctx context.Context, req *ApprovalRequest) (Approval, error) + type BeforeFinisher interface + BeforeFinish func(ctx context.Context, run *Run, msg *model.Message) (bool, error) + type BeforeModeler interface + BeforeModel func(ctx context.Context, run *Run, req *model.Request) error + type BeforeRunner interface + BeforeRun func(ctx context.Context, run *Run, in *RunInput) error + type BeforeTooler interface + BeforeTool func(ctx context.Context, run *Run, plan *ToolPlan) error + type BeforeTurner interface + BeforeTurn func(ctx context.Context, run *Run) error + type Checkpointer interface + Delete func(ctx context.Context, runID string) error + Load func(ctx context.Context, runID string) (*State, error) + Save func(ctx context.Context, st *State) error + type Compaction struct + After int + Before int + Messages []*model.Message + Summary string + type Config struct + Approver Approver + Budget func(model.Usage) error + Checkpointer Checkpointer + Extra map[string]any + Instructions string + Limits Limits + Logger *slog.Logger + MaxTokens int + MaxTurns int + Middlewares []Middleware + Model model.Model + Name string + Output *Output + Parallelism int + Reasoning *model.Reasoning + ResponseFormat *model.ResponseFormat + StopAtTools []string + StopWhen []StopCondition + Stream bool + Temperature *float64 + ToolChoice *model.ToolChoice + ToolMiddlewares []tool.Middleware + Tools *tool.Registry + TopP *float64 + type ContextWrapper interface + WrapContext func(ctx context.Context, run *Run) (_ context.Context, release func()) + type Decision int + const Allowed + const Asked + const Denied + const NoDecision + type Event struct + Agent string + Compaction *Compaction + Delta *model.StreamEvent + Depth int + Handoff *Handoff + Interrupt *Interrupt + Message *model.Message + OutputRetry *OutputRetry + ParentCallID string + Result *Result + RunID string + SessionID string + ToolCall *model.ToolCall + ToolResult *model.ToolResult + Turn int + Type EventType + Usage model.Usage + func (e *Event) Text() string + type EventType string + const EventCompacted + const EventDelta + const EventHandoff + const EventInterrupted + const EventMessage + const EventOutputRetry + const EventRunEnd + const EventRunStart + const EventToolCall + const EventToolResult + const EventTurnStart + type Funcs struct + AfterModelFunc func(ctx context.Context, run *Run, req *model.Request, resp *model.Response) error + AfterRunFunc func(ctx context.Context, run *Run, res *Result) + AfterToolFunc func(ctx context.Context, run *Run, plan *ToolPlan, res *model.ToolResult) error + BeforeFinishFunc func(ctx context.Context, run *Run, msg *model.Message) (bool, error) + BeforeModelFunc func(ctx context.Context, run *Run, req *model.Request) error + BeforeRunFunc func(ctx context.Context, run *Run, in *RunInput) error + BeforeToolFunc func(ctx context.Context, run *Run, plan *ToolPlan) error + BeforeTurnFunc func(ctx context.Context, run *Run) error + MiddlewareName string + RevalidateToolFunc func(ctx context.Context, run *Run, plan *ToolPlan) error + WrapContextFunc func(ctx context.Context, run *Run) (context.Context, func()) + WrapModelFunc func(run *Run, next model.Model) model.Model + WrapToolFunc func(run *Run, next tool.Invoker) tool.Invoker + func (f *Funcs) AfterModel(ctx context.Context, run *Run, req *model.Request, resp *model.Response) error + func (f *Funcs) AfterRun(ctx context.Context, run *Run, res *Result) + func (f *Funcs) AfterTool(ctx context.Context, run *Run, plan *ToolPlan, res *model.ToolResult) error + func (f *Funcs) BeforeFinish(ctx context.Context, run *Run, msg *model.Message) (bool, error) + func (f *Funcs) BeforeModel(ctx context.Context, run *Run, req *model.Request) error + func (f *Funcs) BeforeRun(ctx context.Context, run *Run, in *RunInput) error + func (f *Funcs) BeforeTool(ctx context.Context, run *Run, plan *ToolPlan) error + func (f *Funcs) BeforeTurn(ctx context.Context, run *Run) error + func (f *Funcs) Name() string + func (f *Funcs) RevalidateTool(ctx context.Context, run *Run, plan *ToolPlan) error + func (f *Funcs) WrapContext(ctx context.Context, run *Run) (context.Context, func()) + func (f *Funcs) WrapModel(run *Run, next model.Model) model.Model + func (f *Funcs) WrapTool(run *Run, next tool.Invoker) tool.Invoker + type Guardrail struct + Info any + Kind string + Message string + Name string + type GuardrailError struct + Guardrail Guardrail + Usage model.Usage + func (e *GuardrailError) Error() string + type Handoff struct + CallID string + From string + Input json.RawMessage + To string + Tool string + type Interrupt struct + Requests []*ApprovalRequest + RunID string + State *State + func ResumedCall(ctx context.Context) (intr *Interrupt, approvals map[string]Approval, ok bool) + type Limits struct + InputTokens int + OutputTokens int + Requests int + ToolCalls int + TotalTokens int + type MemoryCheckpointer struct + func NewMemoryCheckpointer() *MemoryCheckpointer + func (c *MemoryCheckpointer) Delete(_ context.Context, runID string) error + func (c *MemoryCheckpointer) Load(_ context.Context, runID string) (*State, error) + func (c *MemoryCheckpointer) Save(_ context.Context, st *State) error + type Middleware interface + Name func() string + type ModelWrapper interface + WrapModel func(run *Run, next model.Model) model.Model + type Output struct + Name string + Retries int + Schema *tool.Schema + type OutputError struct + Attempts int + Output string + Problems []string + func (e *OutputError) Error() string + type OutputRetry struct + Attempt int + Output string + Problems []string + Retries int + type PendingCall struct + Approval *Approval + Call *model.ToolCall + Concurrent bool + Denied bool + ModelArguments json.RawMessage + NeedsApproval bool + Nested *Interrupt + NestedApprovals map[string]Approval + ReadOnly bool + Reason string + Result *model.ToolResult + Resuming bool + Started bool + Values map[string]string + type RememberScope string + const RememberRun + const RememberSession + type Request struct + History []*model.Message + Input *model.Message + Limits *Limits + MaxTurns int + NewSession bool + RunID string + SessionID string + Turns int + Usage model.Usage + Values map[string]string + type Result struct + Agent string + Err error + FinishReason model.FinishReason + Guardrail *Guardrail + Interrupt *Interrupt + Messages []*model.Message + NewMessages []*model.Message + Output string + Reason string + RunID string + Status Status + Turns int + Usage model.Usage + Values map[string]string + func Collect(events iter.Seq2[*Event, error], onEvent func(*Event)) (*Result, error) + func (r *Result) Decode(v any) error + func (r *Result) DecodeAs[T any]() (T, error) + func (r *Result) UnmarshalJSON(b []byte) error + func (r Result) MarshalJSON() ([]byte, error) + type Run struct + func CallingRun(ctx context.Context) *Run + func (r *Run) Agent() string + func (r *Run) Append(msgs ...*model.Message) + func (r *Run) Caller() *Run + func (r *Run) DecodeValue[T any](key string) (T, bool, error) + func (r *Run) Emit(ev *Event) bool + func (r *Run) EncodeValue(key string, v any) error + func (r *Run) Halt(reason string) + func (r *Run) ID() string + func (r *Run) Logger() *slog.Logger + func (r *Run) Messages() []*model.Message + func (r *Run) NewMessages() []*model.Message + func (r *Run) ReplaceMessages(msgs []*model.Message) + func (r *Run) SessionID() string + func (r *Run) SetValue(key, value string) + func (r *Run) System() string + func (r *Run) Tools() []*model.ToolSpec + func (r *Run) Turn() int + func (r *Run) Value(key string) (string, bool) + type RunInput struct + Message *model.Message + NewSession bool + Query string + System string + type Runtime struct + func New(cfg Config) (*Runtime, error) + func (r *Runtime) Config() Config + func (r *Runtime) Discard(ctx context.Context, runID string) error + func (r *Runtime) Resume(ctx context.Context, runID string, approvals map[string]Approval) iter.Seq2[*Event, error] + func (r *Runtime) ResumeState(ctx context.Context, st *State, approvals map[string]Approval) iter.Seq2[*Event, error] + func (r *Runtime) Run(ctx context.Context, req *Request) iter.Seq2[*Event, error] + type State struct + Agent string + FinishReason model.FinishReason + Limits *Limits + MaxTurns int + Messages []*model.Message + OutputRetries int + Pending []*PendingCall + Reason string + RunID string + SessionID string + Start int + Status Status + System string + Turn int + UpdatedAt time.Time + Usage model.Usage + Values map[string]string + Version int + func (s *State) Clone() *State + func (s *State) NewMessages() []*model.Message + type Status string + const StatusBlocked + const StatusCompleted + const StatusFailed + const StatusIncomplete + const StatusInterrupted + const StatusLimitExceeded + const StatusMaxTurns + const StatusRunning + const StatusStopped + func (s Status) Done() bool + func (s Status) Resumable() bool + type Step struct + Message *model.Message + ToolResults []*model.ToolResult + Turn int + Usage model.Usage + type StopCondition func(step *Step) bool + type ToolPlan struct + Call *model.ToolCall + Info tool.Info + Known bool + func (p *ToolPlan) Allow() + func (p *ToolPlan) Approval() (Approval, bool) + func (p *ToolPlan) Ask(reason string) + func (p *ToolPlan) Decision() (Decision, string) + func (p *ToolPlan) Deny(reason string) + func (p *ToolPlan) SetValue(key, value string) + func (p *ToolPlan) Value(key string) (string, bool) + type ToolProvider interface + Tools func() []tool.Tool + type ToolRevalidator interface + RevalidateTool func(ctx context.Context, run *Run, plan *ToolPlan) error + type ToolWrapper interface + WrapTool func(run *Run, next tool.Invoker) tool.Invoker