tool.go

Overview

The tool.go file in the geminitool package provides a lightweight wrapper enabling integration of Gemini-native tools, specifically those defined via the genai API, into the agent tooling framework. It exposes a factory function New to create tools compatible with the generic tool.Tool interface, allowing Gemini tools such as Google Search or data retrieval endpoints to be seamlessly included in LLM requests.

This file’s primary purpose is to bridge Gemini tools (genai.Tool) with the broader agent tooling system by wrapping them in a struct that implements the tool.Tool interface. The wrapped tools can then be attached to LLM generation requests, making their capabilities available during LLM execution without requiring local implementation of the tool logic.

Entities and Functions

New(name string, t *genai.Tool) tool.Tool

type geminiTool

func setTool(req *model.LLMRequest, t *genai.Tool) error

Important Implementation Details

Interaction with Other System Components

Diagram: Class Structure and Method Overview

classDiagram
class geminiTool {
- name: string
- value: *genai.Tool
+ ProcessRequest(ctx, req) error
+ Name() string
+ Description() string
+ IsLongRunning() bool
}
geminiTool ..> genai.Tool : wraps
geminiTool ..|> tool.Tool : implements

Summary

For more on how tools integrate with agent workflows and LLM requests, see the Tooling System and LLM Integration and Agents topics. For specific tool types, the Google Search Tool subtopic provides context on Gemini’s native search tooling.