adk-java icon indicating copy to clipboard operation
adk-java copied to clipboard

[BUG] `BaseTool.ToolConfig.toJson()` throws "No serializer found"

Open SuperCorleone opened this issue 5 months ago • 1 comments

Describe the Bug

ToolConfig exposes fluent accessors name()/args() (not JavaBean getName/getArgs) and carries no Jackson serialization annotations, so Jackson discovers no serializable properties and the inherited toJson() throws InvalidDefinitionException: No serializer found. ToolConfig is deserialized from YAML config (input only) and never serialized in production, so the asymmetry is latent.

Observed Behavior

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class ...ToolConfig and no properties discovered to create BeanSerializer

Suggested Fix

Add Jackson property exposure (e.g. @JsonProperty on the fields/accessors) or document/override that ToolConfig is not serializable.

Corresponding Test (generated)

@Test
public void testToolConfigJsonSerialization() {
    BaseTool.ToolArgsConfig args = new BaseTool.ToolArgsConfig();
    args.put("arg1", "value1");
    args.put("arg2", 456);
    
    BaseTool.ToolConfig config = new BaseTool.ToolConfig("testTool", args);
    
    // Test serialization - we need to ensure the ToolConfig has proper Jackson annotations
    String json = config.toJson();
    assertNotNull(json);
    assertFalse(json.isEmpty());
    assertTrue(json.contains("\"name\":\"testTool\""));
    assertTrue(json.contains("\"args\":"));
}

Environment

  • Project: adk / google-adk (com.google.adk) · upstream: github.com/google/adk-java
  • Version: 0.5.1-SNAPSHOT (local) · Commit: <fill SUT commit> · Java 17 · OS macOS

This input was generated by the test case generator TestFusion developed in our STAR lab.

SuperCorleone avatar Jun 16 '26 14:06 SuperCorleone

Hi @SuperCorleone, Thank you for reporting this issue. I am able to reproduce this issue in latest version which you reported and I have created this PR to resolve this problem. hope this PR will address your issue?

hemasekhar-p avatar Jun 19 '26 11:06 hemasekhar-p