Versions in this module Expand all Collapse all v0 v0.1.1 Jul 8, 2026 v0.1.0 Jul 8, 2026 Changes in this version + var ErrInterrupted = errors.New("execution was interrupted") + var ErrLoopEscalated = errors.New("loop escalated to outer handler") + var ErrMaxIterationsExceeded = errors.New("maximum iterations exceeded in agent execution") + var ErrModelProviderRequired = errors.New("model provider is required") + var ErrNoAgentContext = errors.New("agent not found in context") + var ErrNoFinalResponse = errors.New("stream ended without a final response") + var ErrNoInvocationContext = errors.New("invocation not found in context") + var ErrNoSessionContext = errors.New("session not found in context") + var Version = buildVersion("github.com/CycleZero/blades") + func MergeActions(base, extra map[string]any) map[string]any + func NewAgentContext(ctx context.Context, agent Agent) context.Context + func NewAgentTool(agent Agent) tools.Tool + func NewInvocationID() string + func NewMessageID() string + func NewSessionContext(ctx context.Context, session Session) context.Context + type Agent interface + Description func() string + Name func() string + Run func(context.Context, *Invocation) Generator[*Message, error] + func NewAgent(name string, opts ...AgentOption) (Agent, error) + type AgentContext interface + Description func() string + Name func() string + func FromAgentContext(ctx context.Context) (AgentContext, bool) + type AgentOption func(*agent) + func WithContext(enabled bool) AgentOption + func WithDescription(description string) AgentOption + func WithInputSchema(schema *jsonschema.Schema) AgentOption + func WithInstruction(instruction string) AgentOption + func WithInstructionProvider(p InstructionProvider) AgentOption + func WithMaxIterations(n int) AgentOption + func WithMiddleware(ms ...Middleware) AgentOption + func WithModel(model ModelProvider) AgentOption + func WithOutputKey(key string) AgentOption + func WithOutputSchema(schema *jsonschema.Schema) AgentOption + func WithSkills(skillList ...skills.Skill) AgentOption + func WithTools(tools ...tools.Tool) AgentOption + func WithToolsResolver(r tools.Resolver) AgentOption + type ContextCompressor interface + Compress func(ctx context.Context, messages []*Message) ([]*Message, error) + type DataPart struct + Bytes []byte + MIMEType MIMEType + Name string + type FilePart struct + MIMEType MIMEType + Name string + URI string + type Generator = iter.Seq2[T, E] + type HandleFunc func(context.Context, *Invocation) Generator[*Message, error] + func (f HandleFunc) Handle(ctx context.Context, invocation *Invocation) Generator[*Message, error] + type Handler interface + Handle func(context.Context, *Invocation) Generator[*Message, error] + type InstructionProvider func(ctx context.Context) (string, error) + type Invocation struct + EphemeralMessages []*Message + ID string + Instruction *Message + Message *Message + Model string + Resume bool + Session Session + Stream bool + Tools []tools.Tool + func (inv *Invocation) Clone() *Invocation + type MIMEType string + const MIMEAudioAAC + const MIMEAudioFLAC + const MIMEAudioMP3 + const MIMEAudioOGG + const MIMEAudioOpus + const MIMEAudioPCM + const MIMEAudioWAV + const MIMEImageJPEG + const MIMEImagePNG + const MIMEImageWEBP + const MIMEMarkdown + const MIMEText + const MIMEVideoMP4 + const MIMEVideoOGG + func (m MIMEType) Format() string + func (m MIMEType) Type() string + type Message struct + Actions map[string]any + Author string + FinishReason string + ID string + InvocationID string + Metadata map[string]any + Parts []Part + Role Role + Status Status + TokenUsage TokenUsage + func AppendMessages(base []*Message, extra ...*Message) []*Message + func AssistantMessage(parts ...any) *Message + func MergeParts(base, extra *Message) *Message + func NewAssistantMessage(status Status) *Message + func SystemMessage(parts ...any) *Message + func UserMessage(parts ...any) *Message + func (m *Message) Clone() *Message + func (m *Message) Data() *DataPart + func (m *Message) File() *FilePart + func (m *Message) MarshalJSON() ([]byte, error) + func (m *Message) Reasoning() string + func (m *Message) String() string + func (m *Message) Text() string + func (m *Message) UnmarshalJSON(data []byte) error + type Middleware func(Handler) Handler + func ChainMiddlewares(mws ...Middleware) Middleware + type ModelProvider interface + Generate func(context.Context, *ModelRequest) (*ModelResponse, error) + Name func() string + NewStreaming func(context.Context, *ModelRequest) Generator[*ModelResponse, error] + type ModelRequest struct + InputSchema *jsonschema.Schema + Instruction *Message + Messages []*Message + OutputSchema *jsonschema.Schema + Tools []tools.Tool + type ModelResponse struct + Message *Message + type Part interface + func NewMessageParts(inputs ...any) []Part + type ReasoningPart struct + Text string + type Role string + const RoleAssistant + const RoleSystem + const RoleTool + const RoleUser + type RunOption func(*RunOptions) + func WithInvocationID(invocationID string) RunOption + func WithResume(resume bool) RunOption + func WithSession(session Session) RunOption + type RunOptions struct + InvocationID string + Resume bool + Session Session + type Runner struct + func NewRunner(rootAgent Agent, opts ...RunnerOption) *Runner + func (r *Runner) Run(ctx context.Context, message *Message, opts ...RunOption) (*Message, error) + func (r *Runner) RunStream(ctx context.Context, message *Message, opts ...RunOption) Generator[*Message, error] + type RunnerOption func(*Runner) + type Session interface + Append func(context.Context, *Message) error + History func(ctx context.Context) ([]*Message, error) + ID func() string + SetState func(string, any) + State func() State + func EnsureSession(ctx context.Context) Session + func NewSession(opts ...SessionOption) Session + func SessionFromContext(ctx context.Context) (Session, bool) + type SessionOption func(*sessionInMemory) + func WithContextCompressor(c ContextCompressor) SessionOption + type State map[string]any + func (s State) Clone() State + type Status string + const StatusCompleted + const StatusInProgress + const StatusIncomplete + type TextPart struct + Text string + type TokenCounter interface + Count func(messages ...*Message) int64 + type TokenUsage struct + InputTokens int64 + OutputTokens int64 + TotalTokens int64 + type ToolContext = tools.ToolContext + type ToolPart struct + Completed bool + ID string + Name string + Request string + Response string + func NewToolPart(id, name, request string) ToolPart