Documentation
¶
Overview ¶
Package tool provides tool registration and execution for agent runs.
Index ¶
- func BuildLLMTools(tools []Tool) []llms.Tool
- func ErrorResult(callID, name, code, message, hint string) msg.ToolResultMessage
- func FormatToolError(code, message, hint string) string
- func ValidateArgs(schema map[string]any, args map[string]any) error
- type BatchRequest
- type BatchResult
- type Registry
- type Tool
- type UpdateHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildLLMTools ¶
BuildLLMTools converts registered tools into langchaingo tool definitions.
func ErrorResult ¶ added in v0.95.0
func ErrorResult(callID, name, code, message, hint string) msg.ToolResultMessage
ErrorResult builds an inline tool error result with an actionable message.
func FormatToolError ¶ added in v0.95.0
FormatToolError builds an actionable tool error message for the model.
Types ¶
type BatchRequest ¶
type BatchRequest struct {
Assistant msg.AssistantMessage
Context *msg.Context
Registry *Registry
Mode msg.ToolExecutionMode
Before msg.BeforeToolCallFn
After msg.AfterToolCallFn
Emit func(context.Context, agentevent.Event) error
}
BatchRequest describes one tool execution batch from an assistant turn.
type BatchResult ¶
type BatchResult struct {
Messages []msg.ToolResultMessage
Terminate bool
}
BatchResult is the outcome of executing one assistant tool batch.
func ExecuteBatch ¶
func ExecuteBatch(ctx context.Context, req BatchRequest) (BatchResult, error)
ExecuteBatch runs tool calls from an assistant message and returns tool result messages.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores registered tools and an optional active allowlist.
func (*Registry) ActiveTools ¶
ActiveTools returns tools allowed for the current run.
type Tool ¶
type Tool interface {
Name() string
Description() string
Parameters() map[string]any
Execute(ctx context.Context, id string, args map[string]any, onUpdate UpdateHandler) (msg.ToolResultMessage, error)
}
Tool is an executable capability exposed to the agent loop.
type UpdateHandler ¶
UpdateHandler receives incremental tool execution progress.