Versions in this module Expand all Collapse all v0 v0.11.0 Nov 23, 2026 v0.10.0 Nov 20, 2026 v0.9.1 Nov 19, 2026 v0.9.0 Oct 26, 2026 Changes in this version + const BlockErrorCode + const MinMaxPendingBytes + var ErrAborted = errors.New("agentkit: run aborted") + var ErrBudgetExceeded = errors.New("agentkit: budget exceeded") + var ErrBusy = errors.New("agentkit: agent is busy") + var ErrMaxTurns = errors.New("agentkit: maximum turns reached") + var ErrNoNestedCaller = errors.New(...) + var ErrNotContinuable = errors.New("agentkit: transcript is not continuable") + var ErrRefusal = errors.New("agentkit: model refused the request") + var ErrSessionExists = errors.New("agentkit: session log already exists at path") + var ErrSessionNotEmpty = errors.New(...) + var ErrStreamOverrun = errors.New("agentkit: stream consumer overrun") + var ErrTerminated = errors.New("agentkit: run terminated by an interceptor during a nested call") + var ErrToolRejected = errors.New("agentkit: tool call rejected") + var ErrUnguardedExecute = errors.New(...) + func BatchTerminates(votes []bool) bool + func MarshalEvent(e Event, enc MessageEncoder) ([]byte, error) + func ReportUsage(ctx context.Context, u Usage) + func ShouldIterate(m *AssistantMessage) bool + func StreamChannel(s *EventStream) <-chan StreamEvent + func WithNestedCaller(ctx context.Context, c NestedCaller) context.Context + func WithUsageReporter(ctx context.Context, report func(Usage)) context.Context + type API string + const APIAnthropicMessages + const APIFaux + const APIGoogleGenerative + const APIOllamaChat + const APIOpenAICompletions + const APIOpenAIResponses + type AfterToolCall func(ctx context.Context, in AfterToolCallContext) AfterToolCallDecision + type AfterToolCallContext struct + Arguments map[string]any + Elapsed time.Duration + ParentToolName string + ParentToolUseID string + Result *ToolResultMessage + ToolName string + ToolResult ToolResult + ToolUseID string + type AfterToolCallDecision struct + Terminate *bool + type AgentDoneEvent struct + Result RunResult + Usage Usage + func (AgentDoneEvent) Class() EventClass + func (AgentDoneEvent) EventType() EventType + type AgentStartEvent struct + API API + Model string + Provider string + SessionID string + func (AgentStartEvent) Class() EventClass + func (AgentStartEvent) EventType() EventType + type AssistantMessage struct + Content Content + Effort Effort + ErrorMessage string + Model string + RawStopReason string + ResponseID string + ResponseModel string + StopDetail string + StopReason StopReason + Timestamp time.Time + Usage Usage + func (AssistantMessage) Role() Role + func (m AssistantMessage) Clone() Message + type BeforeToolCall func(ctx context.Context, in BeforeToolCallContext) BeforeToolCallDecision + type BeforeToolCallContext struct + Arguments map[string]any + Assistant *AssistantMessage + Batch []ToolUseBlock + Index int + ParentToolName string + ParentToolUseID string + RawInput json.RawMessage + Tool Tool + ToolName string + ToolUseID string + TurnCount int + type BeforeToolCallDecision struct + Arguments map[string]any + Block bool + Reason string + Terminate bool + type BlockType string + const BlockText + const BlockThinking + const BlockToolUse + type CacheRetention string + const CacheRetentionLong + const CacheRetentionNone + const CacheRetentionShort + type Content []ContentBlock + func (c Content) Clone() Content + func (c Content) Text() string + type ContentBlock interface + BlockType func() BlockType + CloneBlock func() ContentBlock + type Effort string + const EffortHigh + const EffortLow + const EffortMax + const EffortMedium + const EffortXHigh + type ErrorEvent struct + Err error + Message string + Terminal bool + func (ErrorEvent) Class() EventClass + func (ErrorEvent) EventType() EventType + type Event interface + Class func() EventClass + EventType func() EventType + type EventClass uint8 + const ClassAuthoritative + const ClassIncremental + const ClassSnapshot + type EventStream struct + func ErrorStream(msg *AssistantMessage, err error) *EventStream + func EventStreamOf(ch <-chan StreamEvent, err error) *EventStream + func NewEventStream(opts StreamOptions) *EventStream + func (s *EventStream) End(res StreamResult) + func (s *EventStream) Err() error + func (s *EventStream) Events() iter.Seq[Event] + func (s *EventStream) Next() (Event, bool) + func (s *EventStream) Push(e Event) + func (s *EventStream) Result() *AssistantMessage + func (s *EventStream) RunResult() (RunResult, error) + func (s *EventStream) Wait() StreamResult + type EventType string + const EvAgentDone + const EvAgentStart + const EvError + const EvMessageEnd + const EvMessageStart + const EvMessageUpdate + const EvTextDelta + const EvTextEnd + const EvTextStart + const EvThinkingDelta + const EvThinkingEnd + const EvThinkingStart + const EvToolCallEnd + const EvToolCallStart + const EvToolExecutionEnd + const EvToolExecutionStart + const EvToolExecutionUpdate + const EvToolInputDelta + const EvToolResult + const EvTurnEnd + const EvTurnStart + type ExecutionMode uint8 + const Parallel + const Sequential + type Message interface + Clone func() Message + Role func() Role + type MessageEncoder func(Message) (json.RawMessage, error) + type MessageEndEvent struct + Message AssistantMessage + func (MessageEndEvent) Class() EventClass + func (MessageEndEvent) EventType() EventType + type MessageStartEvent struct + Message AssistantMessage + func (MessageStartEvent) Class() EventClass + func (MessageStartEvent) EventType() EventType + type MessageUpdateEvent struct + Message AssistantMessage + func (MessageUpdateEvent) Class() EventClass + func (MessageUpdateEvent) EventType() EventType + type Messages []Message + func (ms Messages) Clone() Messages + type Model struct + CacheReadCostPerMillion float64 + CacheWriteCostPerMillion float64 + Compat json.RawMessage + ContextWindow int + Efforts map[Effort]*string + ID string + InputCostPerMillion float64 + MaxOutputTokens int + OutputCostPerMillion float64 + ThinkingKind ThinkingKind + type NestedCaller interface + Call func(ctx context.Context, calls ...ToolUseBlock) ([]ToolResult, error) + type NoToolsMode string + const NoToolsAll + const NoToolsBuiltin + const NoToolsNone + type PreparedArguments struct + Args map[string]any + Coercions []schema.Coercion + Raw json.RawMessage + func PrepareArguments(t Tool, c ToolUseBlock) (PreparedArguments, error) + func (p PreparedArguments) TryWithArgs(args map[string]any) (PreparedArguments, error) + func (p PreparedArguments) WithArgs(args map[string]any) PreparedArguments + type ProviderClient interface + Stream func(ctx context.Context, req Request) (<-chan StreamEvent, error) + type Request struct + Effort Effort + MaxTokens *int + Messages Messages + Prefix Messages + StopSequences []string + System []ContentBlock + Temperature *float64 + ToolChoice ToolChoice + Tools []ToolWire + TopP *float64 + type ResultHandler func(ctx context.Context, input json.RawMessage) ToolResult + type Role string + const RoleAssistant + const RoleToolResult + const RoleUser + type RunResult struct + Error error + LastReason StopReason + Messages Messages + StopReason RunStopReason + TurnCount int + Usage Usage + func (r RunResult) FinalText() string + type RunStopReason string + const RunStopAborted + const RunStopBudgetExceeded + const RunStopEndTurn + const RunStopError + const RunStopMaxTurns + const RunStopPolicy + const RunStopRefusal + const RunStopTimeout + const RunStopToolTerminate + type StopReason string + const StopReasonAborted + const StopReasonError + const StopReasonLength + const StopReasonRefusal + const StopReasonStop + const StopReasonStopSequence + const StopReasonToolUse + func (r StopReason) ShortCircuits() bool + type StreamEvent struct + Err error + Event Event + type StreamOptions struct + MaxPendingBytes int64 + type StreamResult struct + Err error + Message *AssistantMessage + Result *RunResult + type TextBlock struct + Text string + func (TextBlock) BlockType() BlockType + func (b TextBlock) CloneBlock() ContentBlock + type TextDeltaEvent struct + BlockIndex int + Delta string + func (TextDeltaEvent) Class() EventClass + func (TextDeltaEvent) EventType() EventType + type TextEndEvent struct + BlockIndex int + Text string + func (TextEndEvent) Class() EventClass + func (TextEndEvent) EventType() EventType + type TextStartEvent struct + BlockIndex int + func (TextStartEvent) Class() EventClass + func (TextStartEvent) EventType() EventType + type ThinkingBlock struct + Redacted bool + Signature string + Thinking string + func (ThinkingBlock) BlockType() BlockType + func (b ThinkingBlock) CloneBlock() ContentBlock + type ThinkingDeltaEvent struct + BlockIndex int + Delta string + func (ThinkingDeltaEvent) Class() EventClass + func (ThinkingDeltaEvent) EventType() EventType + type ThinkingEndEvent struct + BlockIndex int + Redacted bool + Signature string + Thinking string + func (ThinkingEndEvent) Class() EventClass + func (ThinkingEndEvent) EventType() EventType + type ThinkingKind string + const ThinkingKindAdaptive + const ThinkingKindBudget + const ThinkingKindNone + type ThinkingStartEvent struct + BlockIndex int + func (ThinkingStartEvent) Class() EventClass + func (ThinkingStartEvent) EventType() EventType + type Tool struct + Builtin bool + Description string + Execute ResultHandler + ExecutionMode ExecutionMode + Handler ToolHandler + InputSchema *schema.Schema + Label string + Name string + OutputSchema *schema.Schema + PrepareArguments func(map[string]any) map[string]any + PromptGuidelines []string + ReachableTools []Tool + Terminating bool + func Named(ts []Tool, names ...string) ([]Tool, error) + func ReachableTools(tools []Tool) []Tool + func (t Tool) Wire() ToolWire + type ToolCallEndEvent struct + Block ToolUseBlock + BlockIndex int + func (ToolCallEndEvent) Class() EventClass + func (ToolCallEndEvent) EventType() EventType + type ToolCallStartEvent struct + BlockIndex int + Name string + ToolUseID string + func (ToolCallStartEvent) Class() EventClass + func (ToolCallStartEvent) EventType() EventType + type ToolChoice string + const ToolChoiceAuto + const ToolChoiceNone + const ToolChoiceUnset + func (c ToolChoice) IsSet() bool + type ToolExecutionEndEvent struct + ElapsedMS int64 + IsError bool + Name string + ParentToolUseID string + Result Content + ToolUseID string + func (ToolExecutionEndEvent) Class() EventClass + func (ToolExecutionEndEvent) EventType() EventType + type ToolExecutionStartEvent struct + Name string + ParentToolUseID string + ToolUseID string + func (ToolExecutionStartEvent) Class() EventClass + func (ToolExecutionStartEvent) EventType() EventType + type ToolExecutionUpdateEvent struct + Chunk string + Name string + ParentToolUseID string + ToolUseID string + func (ToolExecutionUpdateEvent) Class() EventClass + func (ToolExecutionUpdateEvent) EventType() EventType + type ToolHandler func(ctx context.Context, input json.RawMessage) (json.RawMessage, error) + type ToolInputDeltaEvent struct + BlockIndex int + Delta string + ToolUseID string + func (ToolInputDeltaEvent) Class() EventClass + func (ToolInputDeltaEvent) EventType() EventType + type ToolMetadata struct + DurationMS int64 + ExitCode *int + LineEnding string + Outcome string + SpillPath string + TotalBytes int64 + TotalLines int64 + Truncated bool + TruncatedBy string + func (m *ToolMetadata) Clone() *ToolMetadata + func (m *ToolMetadata) IsEmpty() bool + type ToolPolicy struct + CustomTools []Tool + ExcludeTools []string + NoTools NoToolsMode + ToolNames []string + Tools []Tool + func (p ToolPolicy) Resolve(registered []Tool) []Tool + type ToolResult struct + Blocks []ContentBlock + Data map[string]any + Detail string + Error string + Metadata *ToolMetadata + OK bool + Terminate bool + Text string + func CallNested(ctx context.Context, calls ...ToolUseBlock) ([]ToolResult, error) + func ErrResult(code, detail string) ToolResult + func OKResult(data map[string]any) ToolResult + func (r ToolResult) LLMText() string + func (r ToolResult) ToLLMMap() map[string]any + type ToolResultEvent struct + Message ToolResultMessage + func (ToolResultEvent) Class() EventClass + func (ToolResultEvent) EventType() EventType + type ToolResultMessage struct + AddedToolNames []string + Content Content + IsError bool + Metadata *ToolMetadata + Timestamp time.Time + ToolName string + ToolUseID string + Usage *Usage + func (ToolResultMessage) Role() Role + func (m ToolResultMessage) Clone() Message + type ToolUseBlock struct + ID string + Input json.RawMessage + Name string + ThoughtSignature string + func ExtractToolUse(m *AssistantMessage) []ToolUseBlock + func NewToolUse(id, name string, raw json.RawMessage) (ToolUseBlock, error) + func (ToolUseBlock) BlockType() BlockType + func (b ToolUseBlock) CloneBlock() ContentBlock + func (b ToolUseBlock) InputMap() map[string]any + type ToolWire struct + Description string + InputSchema *schema.Schema + Name string + func ToolWires(ts []Tool) []ToolWire + type TurnEndEvent struct + Message AssistantMessage + ToolResults []ToolResultMessage + TurnIndex int + Usage Usage + func (TurnEndEvent) Class() EventClass + func (TurnEndEvent) EventType() EventType + type TurnStartEvent struct + TurnIndex int + func (TurnStartEvent) Class() EventClass + func (TurnStartEvent) EventType() EventType + type Usage struct + BilledModel string + CacheReadTokens int64 + CacheWrite1hTokens int64 + CacheWriteTokens int64 + CostUSD float64 + InputTokens int64 + OutputTokens int64 + ReasoningTokens int64 + Requests int64 + Set UsageField + TotalTokens int64 + Unpriced bool + func (u *Usage) SetCost(v float64) + func (u *Usage) SetField(f UsageField, v int64) + func (u Usage) Add(o Usage) Usage + func (u Usage) ContextTokens() int64 + func (u Usage) Has(f UsageField) bool + func (u Usage) IsZero() bool + func (u Usage) Reported() bool + type UsageField uint32 + const UsageCacheReadTokens + const UsageCacheWrite1hTokens + const UsageCacheWriteTokens + const UsageCostUSD + const UsageInputTokens + const UsageOutputTokens + const UsageReasoningTokens + const UsageTotalTokens + type UsageJSON struct + BilledModel string + CacheReadTokens int64 + CacheWrite1hTokens int64 + CacheWriteTokens int64 + CostUSD float64 + InputTokens int64 + OutputTokens int64 + ReasoningTokens int64 + Reported bool + TotalTokens int64 + Unpriced bool + type UsageWire struct + CacheReadTokens *int64 + CacheWrite1hTokens *int64 + CacheWriteTokens *int64 + InputTokens *int64 + OutputTokens *int64 + ReasoningTokens *int64 + TotalTokens *int64 + func (w UsageWire) Into(u *Usage) + type UserMessage struct + Content Content + Timestamp time.Time + func (UserMessage) Role() Role + func (m UserMessage) Clone() Message