Hey all!
I'm building an Agent, and I'm trying to make it use a custom tool (Extension) that I created, it seems the Java SDK is lacking the ability to register the Tool for use such that it would execute automatically?
The extension is registered (via the experimental UI), the Java SDK I can do:
Tool myTool = Tool.newBuilder()
.addFunctionDeclarations(FunctionDeclaration.newBuilder()
.setName("myTool")
.setDescription("My amazing tool")
.build())
.build();
and later do:
// Create the request to Gemini
GenerateContentRequest request = GenerateContentRequest.newBuilder()
.setModel("gemini-2.0-flash-exp")
.setSystemInstruction(systemInstruction)
.addContents(userMessage)
.setGenerationConfig(generationConfig)
.addTools(myTool) // Register tool with automatic execution ??
.build();
But can't find anywhere to register the Tool's endpoint.
What am I missing here?
Hi @grnadav,
Welcome to Google Cloud Community!
It looks like you are facing an issue with linking the `FunctionDeclaration` in your Java code to the URL endpoint of your custom tool for a Vertex AI Agent.
Here are the potential ways that might help with your use case:
You can refer to the following documentation, which provides information on Google Cloud's Vertex AI and API Gateway:
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.