0

I tried to develop a basic assistant and expose it as a tool in Kotlin, following the examples shown in: quarkus agentic ai

step by step.

However, when I try to use the @Tool annotation in my Kotlin interface

package prova.langchainkotlin import dev.langchain4j.agent.tool.Tool import dev.langchain4j.service.SystemMessage import dev.langchain4j.service.UserMessage import io.quarkiverse.langchain4j.RegisterAiService @RegisterAiService(modelName = "config-assistant") @SystemMessage(""" You are a basic assistant that helps customers in their daily tasks. """) interface ConfigAgent { @UserMessage(""" Provide some basic information to the customer Request: {request} """) @Tool("Provide some basic information to the customer") fun handleRequest(request: String): String } 

it raises this error:

Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [ERROR] [error]: Build step io.quarkus.arc.deployment.ArcProcessor#generateResources threw an exception: jakarta.enterprise.inject.spi.DeploymentException: java.lang.IllegalStateException: TOOL method must not be declared on an interface: ConfigAgent#handleRequest(java.lang.String) [ERROR] at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1581) [ERROR] at io.quarkus.arc.processor.BeanProcessor.processValidationErrors(BeanProcessor.java:198) [ERROR] at io.quarkus.arc.deployment.ArcProcessor.generateResources(ArcProcessor.java:518) [ERROR] at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733) [ERROR] at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856) [ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:255) [ERROR] at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2651) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2630) [ERROR] at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1622) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1589) [ERROR] at java.base/java.lang.Thread.run(Thread.java:1583) [ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:501) [ERROR] Caused by: java.lang.IllegalStateException: TOOL method must not be declared on an interface: ConfigAgent#handleRequest(java.lang.String) [ERROR] at io.quarkiverse.mcp.server.deployment.McpServerProcessor.findWrongMethods(McpServerProcessor.java:365) [ERROR] at io.quarkiverse.mcp.server.deployment.McpServerProcessor.findWrongAnnotationUsage(McpServerProcessor.java:350) [ERROR] at io.quarkiverse.mcp.server.deployment.McpServerProcessor.collectFeatureMethods(McpServerProcessor.java:214) 

Below there is my pom.xml file:

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.acme</groupId> <artifactId>langchain_kotlin</artifactId> <version>1.0.0-SNAPSHOT</version> <properties> <compiler-plugin.version>3.14.0</compiler-plugin.version> <kotlin.version>2.1.21</kotlin.version> <maven.compiler.release>21</maven.compiler.release> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id> <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id> <quarkus.platform.version>3.23.0</quarkus.platform.version> <quarkus.langchain4j.version>0.27.0.CR2</quarkus.langchain4j.version> <skipITs>true</skipITs> <surefire-plugin.version>3.5.2</surefire-plugin.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>${quarkus.platform.group-id}</groupId> <artifactId>${quarkus.platform.artifact-id}</artifactId> <version>${quarkus.platform.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-qute</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-rest-jackson</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-rest-client-jackson</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-kotlin</artifactId> </dependency> <dependency> <groupId>io.quarkiverse.mcp</groupId> <artifactId>quarkus-mcp-server-stdio</artifactId> <version>1.2.1</version> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-arc</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-junit5</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib-jdk8</artifactId> </dependency> <dependency> <groupId>io.rest-assured</groupId> <artifactId>kotlin-extensions</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>io.quarkiverse.langchain4j</groupId> <artifactId>quarkus-langchain4j-ollama</artifactId> <version>${quarkus.langchain4j.version}</version> </dependency> <dependency> <groupId>io.quarkiverse.langchain4j</groupId> <artifactId>quarkus-langchain4j-testing-scorer-junit5</artifactId> <version>${quarkus.langchain4j.version}</version> <scope>test</scope> </dependency> </dependencies> <build> <sourceDirectory>src/main/kotlin</sourceDirectory> <testSourceDirectory>src/test/kotlin</testSourceDirectory> <plugins> <plugin> <groupId>${quarkus.platform.group-id}</groupId> <artifactId>quarkus-maven-plugin</artifactId> <version>${quarkus.platform.version}</version> <extensions>true</extensions> <executions> <execution> <goals> <goal>build</goal> <goal>generate-code</goal> <goal>generate-code-tests</goal> <goal>native-image-agent</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>${compiler-plugin.version}</version> <configuration> <parameters>true</parameters> </configuration> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>${surefire-plugin.version}</version> <configuration> <systemPropertyVariables> <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> <maven.home>${maven.home}</maven.home> </systemPropertyVariables> </configuration> </plugin> <plugin> <artifactId>maven-failsafe-plugin</artifactId> <version>${surefire-plugin.version}</version> <executions> <execution> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> </execution> </executions> <configuration> <systemPropertyVariables> <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> <maven.home>${maven.home}</maven.home> </systemPropertyVariables> </configuration> </plugin> <plugin> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-plugin</artifactId> <version>${kotlin.version}</version> <executions> <execution> <id>compile</id> <goals> <goal>compile</goal> </goals> </execution> <execution> <id>test-compile</id> <goals> <goal>test-compile</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-allopen</artifactId> <version>${kotlin.version}</version> </dependency> </dependencies> <configuration> <javaParameters>true</javaParameters> <jvmTarget>21</jvmTarget> <compilerPlugins> <plugin>all-open</plugin> </compilerPlugins> <pluginOptions> <option>all-open:annotation=jakarta.ws.rs.Path</option> <option>all-open:annotation=jakarta.enterprise.context.ApplicationScoped</option> <option>all-open:annotation=jakarta.persistence.Entity</option> <option>all-open:annotation=io.quarkus.test.junit.QuarkusTest</option> </pluginOptions> </configuration> </plugin> </plugins> </build> <profiles> <profile> <id>native</id> <activation> <property> <name>native</name> </property> </activation> <properties> <skipITs>false</skipITs> <quarkus.native.enabled>true</quarkus.native.enabled> </properties> </profile> </profiles> </project> 

The pom above has been initiated by setting the kotlin and the LangChain4J plugins for quarkus.

5
  • Any chance you can share the project so I can see the problem in action? Commented May 30 at 14:12
  • This is the only class in the project at the moment. Commented May 30 at 14:29
  • How about the build file? Commented May 30 at 14:36
  • I added the pom.xml file Commented May 30 at 14:42
  • 1
    See github.com/quarkiverse/quarkus-langchain4j/issues/1534 Commented Jun 3 at 6:56

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.