Skip to content

armgit / ax

Public Imported from GitHub
0

Agent Executor (AX) is Google's open agentic orchestration runtime

Go

Allow enabling native tools in the Gemini agent (#193)

Jaana Dogan459837368046
diff --git a/internal/controller/gemini.go b/internal/controller/gemini.go
index 975e4eb..49ae201 100644
--- a/internal/controller/gemini.go
+++ b/internal/controller/gemini.go
@@ -78,10 +78,27 @@ func (a *GeminiAgent) Connect(ctx context.Context, execID string, start *proto.A
if cfg.SystemPrompt != "" {
systemPrompt = genai.Text(cfg.SystemPrompt)[0]
}
+ var tools []*genai.Tool
+ for _, t := range cfg.Tools {
+ switch t {
+ case "google_search":
+ tools = append(tools, &genai.Tool{GoogleSearch: &genai.GoogleSearch{}})
+ case "url_context":
+ tools = append(tools, &genai.Tool{URLContext: &genai.URLContext{}})
+ case "code_execution":
+ tools = append(tools, &genai.Tool{CodeExecution: &genai.ToolCodeExecution{}})
+ case "google_maps":
+ tools = append(tools, &genai.Tool{GoogleMaps: &genai.GoogleMaps{}})
+ default:
+ return fmt.Errorf("unsupported tool: %q", t)
+ }
+ }
+
resp, err := client.Models.GenerateContent(ctx, cfg.Model, contents, &genai.GenerateContentConfig{
SystemInstruction: systemPrompt,
MaxOutputTokens: cfg.MaxTokens,
CandidateCount: 1,
+ Tools: tools,
})
if err != nil {
return fmt.Errorf("failed to generate: %w", err)
diff --git a/proto/ax.pb.go b/proto/ax.pb.go
index b3c66e5..cb69358 100644
--- a/proto/ax.pb.go
+++ b/proto/ax.pb.go
@@ -1485,6 +1485,7 @@ type GeminiConfig struct {
SystemPrompt string `protobuf:"bytes,2,opt,name=system_prompt,json=systemPrompt,proto3" json:"system_prompt,omitempty"` // System prompt for the agent
MaxTokens int32 `protobuf:"varint,3,opt,name=max_tokens,json=maxTokens,proto3" json:"max_tokens,omitempty"` // Maximum number of tokens to generate
Timeout *durationpb.Duration `protobuf:"bytes,4,opt,name=timeout,proto3" json:"timeout,omitempty"` // e.g. "10s"
+ Tools []string `protobuf:"bytes,5,rep,name=tools,proto3" json:"tools,omitempty"` // List of enabled tools (e.g. "google_search")
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -1547,6 +1548,13 @@ func (x *GeminiConfig) GetTimeout() *durationpb.Duration {
return nil
}
+func (x *GeminiConfig) GetTools() []string {
+ if x != nil {
+ return x.Tools
+ }
+ return nil
+}
+
var File_proto_ax_proto protoreflect.FileDescriptor
const file_proto_ax_proto_rawDesc = "" +
@@ -1640,13 +1648,14 @@ const file_proto_ax_proto_rawDesc = "" +
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01B\b\n" +
"\x06config\"1\n" +
"\x15RegisterAgentResponse\x12\x18\n" +
- "\ahealthy\x18\x01 \x01(\bR\ahealthy\"\x9d\x01\n" +
+ "\ahealthy\x18\x01 \x01(\bR\ahealthy\"\xb3\x01\n" +
"\fGeminiConfig\x12\x14\n" +
"\x05model\x18\x01 \x01(\tR\x05model\x12#\n" +
"\rsystem_prompt\x18\x02 \x01(\tR\fsystemPrompt\x12\x1d\n" +
"\n" +
"max_tokens\x18\x03 \x01(\x05R\tmaxTokens\x123\n" +
- "\atimeout\x18\x04 \x01(\v2\x19.google.protobuf.DurationR\atimeout*X\n" +
+ "\atimeout\x18\x04 \x01(\v2\x19.google.protobuf.DurationR\atimeout\x12\x14\n" +
+ "\x05tools\x18\x05 \x03(\tR\x05tools*X\n" +
"\x05State\x12\x15\n" +
"\x11STATE_UNSPECIFIED\x10\x00\x12\x11\n" +
"\rSTATE_PENDING\x10\x01\x12\x10\n" +
diff --git a/proto/ax.proto b/proto/ax.proto
index 0a66e9a..1aa1e53 100644
--- a/proto/ax.proto
+++ b/proto/ax.proto
@@ -222,4 +222,5 @@ message GeminiConfig {
string system_prompt = 2; // System prompt for the agent
int32 max_tokens = 3; // Maximum number of tokens to generate
google.protobuf.Duration timeout = 4; // e.g. "10s"
+ repeated string tools = 5; // List of enabled tools (e.g. "google_search")
}