Skip to content

feat(models): add support for gemini server tools (#2241) - #2767

Open
pony-huang wants to merge 2 commits into
agentscope-ai:mainfrom
pony-huang:issue-2241-support-gemini-server-tools
Open

feat(models): add support for gemini server tools (#2241)#2767
pony-huang wants to merge 2 commits into
agentscope-ai:mainfrom
pony-huang:issue-2241-support-gemini-server-tools

Conversation

@pony-huang

@pony-huang pony-huang commented Aug 18, 2026

Copy link
Copy Markdown

AgentScope-Java Version

[The version of AgentScope-Java you are working on, e.g. 1.0.12, check your pom.xml dependency version or run mvn dependency:tree | grep agentscope-parent:pom(only mac/linux)]

Description

[Please describe the background, purpose, changes made, and how to test this PR]

Checklist

Please check the following items before code is ready to be reviewed.

  • [√ ] Code has been formatted with mvn spotless:apply
  • [√] All tests are passing (mvn test)
  • [√ ] Javadoc comments are complete and follow project conventions
  • [√ ] Related documentation has been updated (e.g. links, examples, etc.)
  • [√ ] Code is ready for review

Simple

public class Main {
    public static void main(String[] args) throws JsonProcessingException {

        GeminiChatModel gemini =
                GeminiChatModel.builder()
                        .modelName("gemini-3.5-flash")
                        .streamEnabled(true)
                        .serverTools(List.of(GeminiServerTool.googleSearch().build()))
                        .build();

        Toolkit toolkit = new Toolkit();
        WeatherTools weatherTools = new WeatherTools();
        toolkit.registerTool(weatherTools);
        ReActAgent agent =
                ReActAgent.builder()
                        .name("weather-agent")
                        .model(gemini)
                        .toolkit(toolkit)
                        .maxIters(6)
                        .build();

        Msg response =
                agent.call(
                                new UserMessage(
                                        """
                                        What is the southernmost city in the China? What's the weather like there today?\
                                        """))
                        .block();

        assert response != null;
        System.out.println(response.getTextContent());
        System.out.println(new ObjectMapper().writeValueAsString(response.getMetadata()));
    }

    static final class WeatherTools {

        @Tool(
                name = "getWeather",
                description = "Get the weather in a given location",
                readOnly = true)
        public String getWeather(
                @ToolParam(
                                name = "location",
                                description = "The city and state, e.g. San Francisco, CA",
                                required = true)
                        String location) {

            System.out.println("getWeather called with location: " + location);
            return """
            {
              "response": "Very hot. it's  96.8°F",
            }
            """;
        }
    }
}

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@pony-huang
pony-huang force-pushed the issue-2241-support-gemini-server-tools branch from 0cc6be9 to 6eb4b10 Compare August 18, 2026 17:18
@AgentScopeJavaBot AgentScopeJavaBot added enhancement New feature or request area/core/model Model providers and formatters area/extensions agentscope-extensions (general) area/docs Documentation labels Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core/model Model providers and formatters area/docs Documentation area/extensions agentscope-extensions (general) enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants