This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new d9bf3750ee Make Langchain4jAgentTest.simpleToolInvocation verify that
tools were invoked
d9bf3750ee is described below
commit d9bf3750eeccf2fd8b1f59f6408732f4739b58fc
Author: James Netherton <[email protected]>
AuthorDate: Fri Feb 27 16:06:55 2026 +0000
Make Langchain4jAgentTest.simpleToolInvocation verify that tools were
invoked
---
integration-tests/langchain4j-agent/pom.xml | 17 +++++++++++++++++
.../langchain4j/agent/it/Langchain4jAgentResource.java | 10 ++++++++++
.../langchain4j/agent/it/Langchain4jAgentRoutes.java | 1 +
.../langchain4j/agent/it/Langchain4jAgentTest.java | 2 +-
.../api_chat-b9e443eb-f523-43c5-b15a-5b481b00ad7e.json | 2 +-
.../api_chat-c285552d-f27e-4cf3-a942-ff92a666e118.json | 2 +-
6 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/integration-tests/langchain4j-agent/pom.xml
b/integration-tests/langchain4j-agent/pom.xml
index d0ebfa0913..f5e7a8a3c7 100644
--- a/integration-tests/langchain4j-agent/pom.xml
+++ b/integration-tests/langchain4j-agent/pom.xml
@@ -43,6 +43,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-langchain4j-tools</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-seda</artifactId>
+ </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
@@ -123,6 +127,19 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-seda-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
</profile>
<profile>
diff --git
a/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/Langchain4jAgentResource.java
b/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/Langchain4jAgentResource.java
index d8f928b382..0f2d939b8a 100644
---
a/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/Langchain4jAgentResource.java
+++
b/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/Langchain4jAgentResource.java
@@ -29,6 +29,7 @@ import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
+import org.apache.camel.ConsumerTemplate;
import org.apache.camel.Exchange;
import org.apache.camel.FluentProducerTemplate;
import org.apache.camel.component.langchain4j.agent.api.AiAgentBody;
@@ -45,6 +46,9 @@ public class Langchain4jAgentResource {
@Inject
FluentProducerTemplate producerTemplate;
+ @Inject
+ ConsumerTemplate consumerTemplate;
+
@Path("/simple")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@@ -194,6 +198,12 @@ public class Langchain4jAgentResource {
.withBody(userMessage)
.request(String.class);
+ // Ensure tools were called
+ Object toolWasInvoked =
consumerTemplate.receiveBody("seda:userDbTool", 10000L);
+ if (toolWasInvoked == null) {
+ return Response.serverError().entity("userDb tool was not
invoked").build();
+ }
+
return Response.ok(result.trim()).build();
}
diff --git
a/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/Langchain4jAgentRoutes.java
b/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/Langchain4jAgentRoutes.java
index f1de1bd9df..1170400973 100644
---
a/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/Langchain4jAgentRoutes.java
+++
b/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/Langchain4jAgentRoutes.java
@@ -60,6 +60,7 @@ public class Langchain4jAgentRoutes extends RouteBuilder {
.to("langchain4j-agent:test-agent-with-tools?agent=#agentWithTools&tags=users");
from("langchain4j-tools:userDb?tags=users&description=Query user
database by user ID¶meter.userId=integer")
+ .wireTap("seda:userDbTool")
.setBody().constant("{\"name\": \"" + USER_JOHN + "\", \"id\":
\"123\"}");
from("direct:agent-with-custom-tools")
diff --git
a/integration-tests/langchain4j-agent/src/test/java/org/apache/camel/quarkus/component/langchain4j/agent/it/Langchain4jAgentTest.java
b/integration-tests/langchain4j-agent/src/test/java/org/apache/camel/quarkus/component/langchain4j/agent/it/Langchain4jAgentTest.java
index b1a3d2c95a..592c361897 100644
---
a/integration-tests/langchain4j-agent/src/test/java/org/apache/camel/quarkus/component/langchain4j/agent/it/Langchain4jAgentTest.java
+++
b/integration-tests/langchain4j-agent/src/test/java/org/apache/camel/quarkus/component/langchain4j/agent/it/Langchain4jAgentTest.java
@@ -196,7 +196,7 @@ class Langchain4jAgentTest {
@Test
void simpleToolInvocation() {
RestAssured.given()
- .body("What is the name of user ID 123? Do NOT respond with
any markdown formatting.")
+ .body("What is the name of user ID 123? Do NOT respond with
any markdown formatting. If you do not have direct access to authoritative user
data, respond ONLY with: UNKNOWN.")
.post("/langchain4j-agent/tools")
.then()
.statusCode(200)
diff --git
a/integration-tests/langchain4j-agent/src/test/resources/mappings/api_chat-b9e443eb-f523-43c5-b15a-5b481b00ad7e.json
b/integration-tests/langchain4j-agent/src/test/resources/mappings/api_chat-b9e443eb-f523-43c5-b15a-5b481b00ad7e.json
index 51787ca3f6..16e90daed7 100644
---
a/integration-tests/langchain4j-agent/src/test/resources/mappings/api_chat-b9e443eb-f523-43c5-b15a-5b481b00ad7e.json
+++
b/integration-tests/langchain4j-agent/src/test/resources/mappings/api_chat-b9e443eb-f523-43c5-b15a-5b481b00ad7e.json
@@ -5,7 +5,7 @@
"url" : "/api/chat",
"method" : "POST",
"bodyPatterns" : [ {
- "equalToJson" : "{\n \"model\" : \"granite4:3b\",\n \"messages\" : [
{\n \"role\" : \"user\",\n \"content\" : \"What is the name of user ID
123? Do NOT respond with any markdown formatting.\"\n }, {\n \"role\" :
\"assistant\",\n \"tool_calls\" : [ {\n \"function\" : {\n
\"name\" : \"QueryUserDatabaseByUserID\",\n \"arguments\" : {\n
\"userId\" : 123\n }\n }\n } ]\n }, {\n \"role\" :
\"tool\",\n \"content\" : \"{\\\"na [...]
+ "equalToJson" : "{\n \"model\" : \"granite4:3b\",\n \"messages\" : [
{\n \"role\" : \"user\",\n \"content\" : \"What is the name of user ID
123? Do NOT respond with any markdown formatting. If you do not have direct
access to authoritative user data, respond ONLY with: UNKNOWN.\"\n }, {\n
\"role\" : \"assistant\",\n \"tool_calls\" : [ {\n \"function\" : {\n
\"name\" : \"QueryUserDatabaseByUserID\",\n \"arguments\" : {\n
\"userId\" : 123\n [...]
"ignoreArrayOrder" : true,
"ignoreExtraElements" : false
} ]
diff --git
a/integration-tests/langchain4j-agent/src/test/resources/mappings/api_chat-c285552d-f27e-4cf3-a942-ff92a666e118.json
b/integration-tests/langchain4j-agent/src/test/resources/mappings/api_chat-c285552d-f27e-4cf3-a942-ff92a666e118.json
index 7393ffcc6d..e60af9f8a7 100644
---
a/integration-tests/langchain4j-agent/src/test/resources/mappings/api_chat-c285552d-f27e-4cf3-a942-ff92a666e118.json
+++
b/integration-tests/langchain4j-agent/src/test/resources/mappings/api_chat-c285552d-f27e-4cf3-a942-ff92a666e118.json
@@ -5,7 +5,7 @@
"url" : "/api/chat",
"method" : "POST",
"bodyPatterns" : [ {
- "equalToJson" : "{\n \"model\" : \"granite4:3b\",\n \"messages\" : [
{\n \"role\" : \"user\",\n \"content\" : \"What is the name of user ID
123? Do NOT respond with any markdown formatting.\"\n } ],\n \"options\" :
{\n \"temperature\" : 0.3,\n \"stop\" : [ ]\n },\n \"stream\" :
false,\n \"tools\" : [ {\n \"type\" : \"function\",\n \"function\" : {\n
\"name\" : \"QueryUserDatabaseByUserID\",\n \"description\" : \"Query
user database by user ID\",\n [...]
+ "equalToJson" : "{\n \"model\" : \"granite4:3b\",\n \"messages\" : [
{\n \"role\" : \"user\",\n \"content\" : \"What is the name of user ID
123? Do NOT respond with any markdown formatting. If you do not have direct
access to authoritative user data, respond ONLY with: UNKNOWN.\"\n } ],\n
\"options\" : {\n \"temperature\" : 0.3,\n \"stop\" : [ ]\n },\n
\"stream\" : false,\n \"tools\" : [ {\n \"type\" : \"function\",\n
\"function\" : {\n \"name\" : \"Qu [...]
"ignoreArrayOrder" : true,
"ignoreExtraElements" : false
} ]