diff --git a/core/deployment/src/main/java/io/quarkiverse/langchain4j/deployment/ToolProcessor.java b/core/deployment/src/main/java/io/quarkiverse/langchain4j/deployment/ToolProcessor.java index 478448e8f..eb67c7dd1 100644 --- a/core/deployment/src/main/java/io/quarkiverse/langchain4j/deployment/ToolProcessor.java +++ b/core/deployment/src/main/java/io/quarkiverse/langchain4j/deployment/ToolProcessor.java @@ -203,7 +203,14 @@ public void handleTools(CombinedIndexBuildItem indexBuildItem, memoryIdParameter = parameter; continue; } - builder.addParameter(parameter.name(), toJsonSchemaProperties(parameter, index)); + + AnnotationInstance pInstance = parameter.annotation(P); + if (pInstance != null && pInstance.value("required") != null + && !pInstance.value("required").asBoolean()) { + builder.addOptionalParameter(parameter.name(), toJsonSchemaProperties(parameter, index)); + } else { + builder.addParameter(parameter.name(), toJsonSchemaProperties(parameter, index)); + } } Map nameToParamPosition = toolMethod.parameters().stream().collect(