Skip to content

Result of tool call ignored if the result is not put under the "result" key #566

@wiesenfeK

Description

@wiesenfeK
Image

Describe the bug
I am invoking a tool and the result is ignored except if I wrap it in the "result" key of the returned map.

Using this:

dependencies {
    implementation(group: 'com.google.adk', name: 'google-adk-dev', version: '0.3.0')
    implementation(group: 'com.google.adk', name: 'google-adk', version: '0.3.0')
}

To Reproduce

With the return Map.of("count", 123L), the agent does not pick up the result.
If i replace it with Map.of("result", 123L), all works well.

public class AdkPOC {

    private static final String CLAUDE_MODEL_ID = "claude-haiku-4-5";

    public static void main(String[] args) {

        var anthropicClient = AnthropicOkHttpClient.builder()
                .apiKey(System.getenv("ANTHROPIC_API_KEY"))
                .build();

        var claudeModel = new Claude(
                CLAUDE_MODEL_ID,
                anthropicClient
        );

        var dataAnalyst = LlmAgent.builder()
                .name("Data Analyst")
                .description("An agent to perform data analytics with multiple tools")
                .model(claudeModel)
                .tools(FunctionTool.create(AdkPOC.class, "getRowCount"))
                .build();

        AdkWebServer.start(dataAnalyst);
    }

    public static Map<String, Object> getRowCount(
            @Schema(name = "dataSetName", description = "The name of the dataset to query")
            String sheetName
    ) {
        return Map.of("count", 123L);
    }
}

Expected behavior

I would expect that the structure of the resulting map is not imposed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions