Documentation
¶
Index ¶
- func ExecuteToolCalls(ctx context.Context, calls []ai.ToolCall, tools ToolSet, cb ToolCallbacks) ([]ai.ToolResultMessage, error)
- type AgentErrored
- type AgentFinished
- type AgentStarted
- type AssistantDelta
- type AssistantFinished
- type AssistantStarted
- type Engine
- type LoopConfig
- type LoopEvent
- type ToolCallbacks
- type ToolFinished
- type ToolFunc
- type ToolSet
- type ToolStarted
- type TurnFinished
- type TurnStarted
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteToolCalls ¶
func ExecuteToolCalls(ctx context.Context, calls []ai.ToolCall, tools ToolSet, cb ToolCallbacks) ([]ai.ToolResultMessage, error)
ExecuteToolCalls runs each tool call in order and returns result messages.
Types ¶
type AgentErrored ¶
type AgentErrored struct {
Err error
}
AgentErrored is emitted for terminal loop errors.
func (AgentErrored) Kind ¶
func (AgentErrored) Kind() string
type AgentFinished ¶
type AgentFinished struct{}
AgentFinished is emitted when loop completes.
func (AgentFinished) Kind ¶
func (AgentFinished) Kind() string
type AgentStarted ¶
type AgentStarted struct{}
AgentStarted is emitted when a loop begins.
func (AgentStarted) Kind ¶
func (AgentStarted) Kind() string
type AssistantDelta ¶
type AssistantDelta struct {
Event ai.AssistantEvent
Message ai.AssistantMessage
}
AssistantDelta forwards an incremental provider event with the current partial message.
func (AssistantDelta) Kind ¶
func (AssistantDelta) Kind() string
type AssistantFinished ¶
type AssistantFinished struct {
Message ai.AssistantMessage
}
AssistantFinished is emitted when the final assistant message is assembled.
func (AssistantFinished) Kind ¶
func (AssistantFinished) Kind() string
type AssistantStarted ¶
type AssistantStarted struct {
Message ai.AssistantMessage
}
AssistantStarted is emitted when assistant streaming begins.
func (AssistantStarted) Kind ¶
func (AssistantStarted) Kind() string
type Engine ¶
type Engine struct {
Providers ai.ProviderGetter
}
Engine coordinates model generation and tool execution.
func (*Engine) Continue ¶
func (e *Engine) Continue(ctx context.Context, cfg LoopConfig, history []ai.Message, emit func(LoopEvent)) ([]ai.Message, error)
Continue validates that the transcript tail is a user or tool-result message and resumes the agent loop from the existing history.
func (*Engine) Run ¶
func (e *Engine) Run(ctx context.Context, cfg LoopConfig, history []ai.Message, emit func(LoopEvent)) ([]ai.Message, error)
Run executes the agent loop: repeatedly generating assistant responses and executing tool calls until the model stops calling tools, the turn limit is reached, or an interrupt/error occurs.
type LoopConfig ¶
type LoopConfig struct {
Model ai.Model
StreamOptions ai.StreamOptions
MaxTurns int
Tools ToolSet
ToolDefinitions []ai.ToolDefinition
System string
Interrupt <-chan struct{}
}
LoopConfig configures the agent loop behavior.
type LoopEvent ¶
type LoopEvent interface {
Kind() string
}
LoopEvent is the runtime event contract emitted by the agent loop.
type ToolCallbacks ¶
type ToolCallbacks struct {
OnStart func(call ai.ToolCall)
OnFinish func(result ai.ToolResultMessage)
}
ToolCallbacks emits progress events around tool execution.
type ToolFinished ¶
type ToolFinished struct {
Result ai.ToolResultMessage
}
ToolFinished is emitted when tool returns.
func (ToolFinished) Kind ¶
func (ToolFinished) Kind() string
type ToolStarted ¶
ToolStarted is emitted for each tool invocation.
func (ToolStarted) Kind ¶
func (ToolStarted) Kind() string
type TurnFinished ¶
type TurnFinished struct {
Turn int
}
TurnFinished is emitted at the end of each loop turn.
func (TurnFinished) Kind ¶
func (TurnFinished) Kind() string
type TurnStarted ¶
type TurnStarted struct {
Turn int
}
TurnStarted is emitted at the start of each loop turn.
func (TurnStarted) Kind ¶
func (TurnStarted) Kind() string