Documentation
¶
Overview ¶
Package tool defines the Tool interface and its variants (SchemaTool, FuncTool) that agents expose to models. Concrete implementations live in the subpackages functool (Go functions), agenttool (an agent as a tool), hostedtool, mcptool, and shelltool.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApprovalRequiredTool ¶
type ApprovalRequiredTool interface {
Tool
// ApprovalRequired reports whether the tool requires user approval before invocation.
ApprovalRequired() bool
}
ApprovalRequiredTool indicates whether a tool requires user approval before invocation.
type FuncTool ¶
type FuncTool interface {
SchemaTool
// Call invokes the tool with raw JSON arguments.
Call(ctx context.Context, args string) (any, error)
}
FuncTool describes a schema-aware tool that can be invoked by an agent.
func ApprovalRequiredFunc ¶
ApprovalRequiredFunc wraps a tool to indicate that it requires user approval before invocation. If the tool already requires approval, it is returned as-is. Not all tools support approval, in which case the original tool is returned.
type SchemaTool ¶
type SchemaTool interface {
Tool
// Schema returns the tool input schema.
Schema() any
// ReturnSchema returns the tool output schema.
ReturnSchema() any
}
SchemaTool describes a tool that exposes input and output schemas.
type Tool ¶
type Tool interface {
// Name returns the provider-facing tool name.
Name() string
// Description returns the provider-facing tool description.
Description() string
}
Tool describes a tool that can be made available to an agent.
type ToolMode ¶
type ToolMode string
ToolMode represents how tools should be used by the agent.
func RequireTool ¶
RequireTool returns a ToolMode that requires the named tool to be used.
func (ToolMode) Mode ¶
Mode returns the base tool mode represented by m. Modes created by RequireTool return ToolModeRequired.
func (ToolMode) RequiredTool ¶
RequiredTool returns the specific tool name required by m. It returns false unless m was created by RequireTool.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agenttool adapts an agent.Agent into a tool.FuncTool via New, so one agent can be invoked as a tool by another.
|
Package agenttool adapts an agent.Agent into a tool.FuncTool via New, so one agent can be invoked as a tool by another. |
|
Package functool turns a typed Go function into a tool.FuncTool via New and MustNew, deriving the tool's input and output JSON schemas from the function's parameter and return types.
|
Package functool turns a typed Go function into a tool.FuncTool via New and MustNew, deriving the tool's input and output JSON schemas from the function's parameter and return types. |
|
Package hostedtool provides definitions for hosted tools.
|
Package hostedtool provides definitions for hosted tools. |
|
Package mcptool provides integration with the Model Context Protocol (MCP).
|
Package mcptool provides integration with the Model Context Protocol (MCP). |
|
Package shelltool provides a shell command execution tool that can be registered with an agent.
|
Package shelltool provides a shell command execution tool that can be registered with an agent. |