Fix Gemini Tool Calling for texts returned from MethodToolCallback

Signed-off-by: nlinhvu <nlinhvu.dev@gmail.com>
This commit is contained in:
nlinhvu
2025-05-08 10:30:34 +07:00
committed by Christian Tzolov
parent 499e8baae5
commit f2df87b567
4 changed files with 54 additions and 4 deletions

View File

@@ -45,7 +45,7 @@ public final class DefaultToolCallResultConverter implements ToolCallResultConve
public String convert(@Nullable Object result, @Nullable Type returnType) {
if (returnType == Void.TYPE) {
logger.debug("The tool has no return type. Converting to conventional response.");
return "Done";
return JsonParser.toJson("Done");
}
if (result instanceof RenderedImage) {
final var buf = new ByteArrayOutputStream(1024 * 4);

View File

@@ -50,9 +50,9 @@ class DefaultToolCallResultConverterTests {
}
@Test
void convertVoidReturnTypeShouldReturnDone() {
void convertVoidReturnTypeShouldReturnDoneJson() {
String result = this.converter.convert(null, void.class);
assertThat(result).isEqualTo("Done");
assertThat(result).isEqualTo("\"Done\"");
}
@Test