tools

package
v0.16.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package tools provides built-in tool implementations for the agent loop.

Index

Constants

This section is empty.

Variables

View Source
var ErrWebFetchAuthRequired = errors.New("web fetch requires authentication")

ErrWebFetchAuthRequired is returned when web fetch requires authentication

View Source
var ErrWebSearchAuthRequired = errors.New("web search requires authentication")

ErrWebSearchAuthRequired is returned when web search requires authentication

Functions

This section is empty.

Types

type BashTool

type BashTool struct{}

BashTool implements shell command execution.

func (*BashTool) Description

func (b *BashTool) Description() string

Description returns a description of the tool.

func (*BashTool) Execute

func (b *BashTool) Execute(args map[string]any) (string, error)

Execute runs the bash command.

func (*BashTool) Name

func (b *BashTool) Name() string

Name returns the tool name.

func (*BashTool) Schema

func (b *BashTool) Schema() api.ToolFunction

Schema returns the tool's parameter schema.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages available tools.

func DefaultRegistry

func DefaultRegistry() *Registry

DefaultRegistry creates a registry with all built-in tools. Tools can be disabled via environment variables: - OLLAMA_AGENT_DISABLE_WEBSEARCH=1 disables web_search - OLLAMA_AGENT_DISABLE_BASH=1 disables bash

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new tool registry.

func (*Registry) Count

func (r *Registry) Count() int

Count returns the number of registered tools.

func (*Registry) Execute

func (r *Registry) Execute(call api.ToolCall) (string, error)

Execute runs a tool call and returns the result.

func (*Registry) Get

func (r *Registry) Get(name string) (Tool, bool)

Get retrieves a tool by name.

func (*Registry) Has

func (r *Registry) Has(name string) bool

Has checks if a tool with the given name is registered.

func (*Registry) Names

func (r *Registry) Names() []string

Names returns the names of all registered tools, sorted alphabetically.

func (*Registry) Register

func (r *Registry) Register(tool Tool)

Register adds a tool to the registry.

func (*Registry) RegisterBash

func (r *Registry) RegisterBash()

RegisterBash adds the bash tool to the registry.

func (*Registry) RegisterWebFetch

func (r *Registry) RegisterWebFetch()

RegisterWebFetch adds the web fetch tool to the registry.

func (*Registry) RegisterWebSearch

func (r *Registry) RegisterWebSearch()

RegisterWebSearch adds the web search tool to the registry.

func (*Registry) Tools

func (r *Registry) Tools() api.Tools

Tools returns all registered tools in Ollama API format, sorted by name.

func (*Registry) Unregister

func (r *Registry) Unregister(name string)

Unregister removes a tool from the registry by name.

type Tool

type Tool interface {
	// Name returns the tool's unique identifier.
	Name() string
	// Description returns a human-readable description of what the tool does.
	Description() string
	// Schema returns the tool's parameter schema for the LLM.
	Schema() api.ToolFunction
	// Execute runs the tool with the given arguments.
	Execute(args map[string]any) (string, error)
}

Tool defines the interface for agent tools.

type WebFetchTool

type WebFetchTool struct{}

WebFetchTool implements web page fetching using Ollama's hosted API.

func (*WebFetchTool) Description

func (w *WebFetchTool) Description() string

Description returns a description of the tool.

func (*WebFetchTool) Execute

func (w *WebFetchTool) Execute(args map[string]any) (string, error)

Execute fetches content from a web page. Uses Ollama key signing for authentication - this makes requests via ollama.com API.

func (*WebFetchTool) Name

func (w *WebFetchTool) Name() string

Name returns the tool name.

func (*WebFetchTool) Schema

func (w *WebFetchTool) Schema() api.ToolFunction

Schema returns the tool's parameter schema.

type WebSearchTool

type WebSearchTool struct{}

WebSearchTool implements web search using Ollama's hosted API.

func (*WebSearchTool) Description

func (w *WebSearchTool) Description() string

Description returns a description of the tool.

func (*WebSearchTool) Execute

func (w *WebSearchTool) Execute(args map[string]any) (string, error)

Execute performs the web search. Uses Ollama key signing for authentication - this makes requests via ollama.com API.

func (*WebSearchTool) Name

func (w *WebSearchTool) Name() string

Name returns the tool name.

func (*WebSearchTool) Schema

func (w *WebSearchTool) Schema() api.ToolFunction

Schema returns the tool's parameter schema.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL