Documentation
¶
Overview ¶
Package tool defines the interfaces for tools that can be called by an agent. A tool is a piece of code that performs a specific task. You can either define your own custom tools or use built-in ones, for example, GoogleSearch.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context interface {
agent.CallbackContext
// FunctionCallID returns the unique identifier of the function call
// that triggered this tool execution.
FunctionCallID() string
// Actions returns the EventActions for the current event. This can be
// used by the tool to modify the agent's state, transfer to another
// agent, or perform other actions.
Actions() *session.EventActions
// SearchMemory performs a semantic search on the agent's memory.
SearchMemory(context.Context, string) (*memory.SearchResponse, error)
}
Context defines the interface for the context passed to a tool when it's called. It provides access to invocation-specific information and allows the tool to interact with the agent's state and memory.
type Predicate ¶
type Predicate func(ctx agent.ReadonlyContext, tool Tool) bool
Predicate is a function which decides whether a tool should be exposed to LLM.
func StringPredicate ¶
StringPredicate is a helper that creates a Predicate from a string slice.
type Tool ¶
type Tool interface {
// Name returns the name of the tool.
Name() string
// Description returns a description of the tool.
Description() string
// IsLongRunning indicates whether the tool is a long-running operation,
// which typically returns a resource id first and finishes the operation later.
IsLongRunning() bool
}
Tool defines the interface for a callable tool.
type Toolset ¶
type Toolset interface {
// Name returns the name of the toolset.
Name() string
// Tools returns a list of tools in the toolset. The provided
// ReadonlyContext can be used to dynamically determine which tools
// to return based on the current invocation state.
Tools(ctx agent.ReadonlyContext) ([]Tool, error)
}
Toolset is an interface for a collection of tools. It allows grouping related tools together and providing them to an agent.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agenttool provides a tool that allows an agent to call another agent.
|
Package agenttool provides a tool that allows an agent to call another agent. |
|
Package exitlooptool provides a tool that allows an agent to exit a loop.
|
Package exitlooptool provides a tool that allows an agent to exit a loop. |
|
Package functiontool provides a tool that wraps a Go function.
|
Package functiontool provides a tool that wraps a Go function. |
|
Package geminitool provides access to Gemini native tools.
|
Package geminitool provides access to Gemini native tools. |
|
Package loadartifactstool defines a tool for loading artifacts.
|
Package loadartifactstool defines a tool for loading artifacts. |
|
Package mcptoolset provides an MCP tool set.
|
Package mcptoolset provides an MCP tool set. |