You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gf...@apache.org on 2026/08/12 14:35:12 UTC

(camel-quarkus) branch feat/8857-improve-langchain4j-agent-test created (now 8f327e79e3)

This is an automated email from the ASF dual-hosted git repository.

gansheer pushed a change to branch feat/8857-improve-langchain4j-agent-test
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


      at 8f327e79e3 Fixes #8857. Tighten langchain4j agent MCP test coverage

This branch includes the following new commits:

     new 4b51ad971c wip
     new 8f327e79e3 Fixes #8857. Tighten langchain4j agent MCP test coverage

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(camel-quarkus) 01/02: wip

Posted by gf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gansheer pushed a commit to branch feat/8857-improve-langchain4j-agent-test
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit 4b51ad971ce0878e02fc2fdc300572f60636031a
Author: Gaelle Fournier <ga...@gmail.com>
AuthorDate: Wed Aug 12 14:26:38 2026 +0200

    wip
---
 .../langchain4j/agent/it/AgentProducers.java       | 34 +++++++++
 .../agent/it/Langchain4jAgentResource.java         | 75 ++++++++++++++++++++
 .../agent/it/Langchain4jAgentRoutes.java           | 26 +++++++
 .../langchain4j/agent/it/model/TestPojo.java       |  3 +
 .../src/main/resources/application.properties      |  2 +-
 .../main/resources/schemas/test-pojo-schema.json   | 18 +++++
 .../langchain4j/agent/it/Langchain4jAgentTest.java | 80 ++++++++++++++++++++++
 ..._chat-87f109c4-a6de-4770-bab4-8bbbdc5f6d4a.json |  6 +-
 ..._chat-a1b2c3d4-e5f6-7890-abcd-ef1234567890.json | 24 +++++++
 ...chat-b2c3d4e5-f6a7-8901-bcde-f12345678901.json} | 10 +--
 ..._chat-c85f8b72-57ab-4cce-9992-6114020e011a.json |  2 +-
 11 files changed, 270 insertions(+), 10 deletions(-)

diff --git a/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/AgentProducers.java b/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/AgentProducers.java
index f38e653efc..38dd88a265 100644
--- a/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/AgentProducers.java
+++ b/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/AgentProducers.java
@@ -225,6 +225,40 @@ public class AgentProducers {
                 .withCustomTools(List.of(new AdditionTool())));
     }
 
+    @Produces
+    @Identifier("agentConfigSimple")
+    AgentConfiguration agentConfigSimple(@Identifier("ollamaOrcaMiniModel") ChatModel chatModel) {
+        return new AgentConfiguration().withChatModel(chatModel);
+    }
+
+    @Produces
+    @Identifier("agentConfigWithMemory")
+    AgentConfiguration agentConfigWithMemory(@Identifier("granite4Model") ChatModel chatModel,
+            ChatMemoryStore chatMemoryStore) {
+        ChatMemoryProvider chatMemoryProvider = memoryId -> MessageWindowChatMemory.builder()
+                .id(memoryId)
+                .maxMessages(10)
+                .chatMemoryStore(chatMemoryStore)
+                .build();
+        return new AgentConfiguration()
+                .withChatModel(chatModel)
+                .withChatMemoryProvider(chatMemoryProvider);
+    }
+
+    @Produces
+    @Identifier("agentConfigForMcp")
+    AgentConfiguration agentConfigForMcp(@Identifier("granite4Model") ChatModel chatModel) {
+        if (isNodeJSInstaled) {
+            return new AgentConfiguration()
+                    .withChatModel(chatModel)
+                    .withMcpToolProviderFilter((mcpClient, toolSpecification) -> {
+                        String toolName = toolSpecification.name().toLowerCase();
+                        return toolName.contains("add") || toolName.contains("echo") || toolName.contains("long");
+                    });
+        }
+        return null;
+    }
+
     @Produces
     @Identifier("agentWithMcpClient")
     Agent agentWithMcpClient(@Identifier("granite4Model") ChatModel chatModel) {
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 0f2d939b8a..b831b6db0f 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
@@ -252,4 +252,79 @@ public class Langchain4jAgentResource {
                 .header(HttpHeaders.CONTENT_TYPE, contentType)
                 .build();
     }
+
+    @Path("/structured-output/class")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response structuredOutputClass(String userMessage) {
+        String result = producerTemplate.to("direct:structured-output-class")
+                .withBody(userMessage)
+                .request(String.class);
+
+        return Response.ok(result.trim())
+                .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                .build();
+    }
+
+    @Path("/structured-output/json-schema")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response structuredOutputJsonSchema(String userMessage) {
+        String result = producerTemplate.to("direct:structured-output-json-schema")
+                .withBody(userMessage)
+                .request(String.class);
+
+        return Response.ok(result.trim())
+                .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                .build();
+    }
+
+    @Path("/auto-provision/simple")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response autoProvisionSimple(String userMessage) {
+        String result = producerTemplate.to("direct:auto-provision-simple")
+                .withBody(userMessage)
+                .request(String.class);
+
+        return Response.ok(result.trim()).build();
+    }
+
+    @Path("/auto-provision/memory")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response autoProvisionMemory(
+            @QueryParam("memoryId") String memoryId,
+            String userMessage) {
+
+        Map<String, Object> headers = new HashMap<>();
+        headers.put(MEMORY_ID, memoryId);
+
+        String result = producerTemplate.to("direct:auto-provision-memory")
+                .withBody(userMessage)
+                .withHeaders(headers)
+                .request(String.class);
+
+        return Response.ok(result.trim()).build();
+    }
+
+    @Path("/mcp/server-config")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(value = { MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON })
+    public Response mcpServerConfig(String userMessage) {
+        String result = producerTemplate.to("direct:mcp-server-config")
+                .withBody(userMessage)
+                .request(String.class);
+
+        String contentType = userMessage.contains("JSON") ? MediaType.APPLICATION_JSON : MediaType.TEXT_PLAIN;
+
+        return Response.ok(result.trim())
+                .header(HttpHeaders.CONTENT_TYPE, contentType)
+                .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 1a53f7d32c..ca6272efcd 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
@@ -18,6 +18,7 @@ package org.apache.camel.quarkus.component.langchain4j.agent.it;
 
 import jakarta.enterprise.context.ApplicationScoped;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.quarkus.component.langchain4j.agent.it.util.ProcessUtils;
 import org.eclipse.microprofile.config.inject.ConfigProperty;
 
 @ApplicationScoped
@@ -66,9 +67,34 @@ public class Langchain4jAgentRoutes extends RouteBuilder {
         from("direct:agent-with-custom-tools")
                 .to("langchain4j-agent:test-agent-custom-tools?agent=#agentWithCustomTools");
 
+        // Structured output - outputClass
+        from("direct:structured-output-class")
+                .to("langchain4j-agent:test-so-class?agentConfiguration=#agentConfigSimple"
+                        + "&outputClass=org.apache.camel.quarkus.component.langchain4j.agent.it.model.TestPojo");
+
+        // Structured output - jsonSchema from classpath resource
+        from("direct:structured-output-json-schema")
+                .to("langchain4j-agent:test-so-schema?agentConfiguration=#agentConfigSimple"
+                        + "&jsonSchema=resource:classpath:schemas/test-pojo-schema.json");
+
+        // AgentConfiguration auto-provisioning without memory
+        from("direct:auto-provision-simple")
+                .to("langchain4j-agent:test-auto-simple?agentConfiguration=#agentConfigSimple");
+
+        // AgentConfiguration auto-provisioning with memory
+        from("direct:auto-provision-memory")
+                .to("langchain4j-agent:test-auto-memory?agentConfiguration=#agentConfigWithMemory");
+
         if (isNodeJSInstaled) {
             from("direct:agent-with-mcp-client")
                     .to("langchain4j-agent:test-agent-with-mcp-client?agent=#agentWithMcpClient");
+
+            // MCP server config via inline URI options
+            from("direct:mcp-server-config")
+                    .to("langchain4j-agent:test-mcp-config?agentConfiguration=#agentConfigForMcp"
+                            + "&mcpServer.everything.transportType=stdio"
+                            + "&mcpServer.everything.command=" + ProcessUtils.getNpxExecutable()
+                            + ",-y,@modelcontextprotocol/server-everything@2025.12.18");
         }
     }
 }
diff --git a/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/model/TestPojo.java b/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/model/TestPojo.java
index be28be175c..02e6c16071 100644
--- a/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/model/TestPojo.java
+++ b/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/model/TestPojo.java
@@ -16,5 +16,8 @@
  */
 package org.apache.camel.quarkus.component.langchain4j.agent.it.model;
 
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
 public record TestPojo(String name, String description) {
 }
diff --git a/integration-tests/langchain4j-agent/src/main/resources/application.properties b/integration-tests/langchain4j-agent/src/main/resources/application.properties
index e336e0a1bc..ec950db064 100644
--- a/integration-tests/langchain4j-agent/src/main/resources/application.properties
+++ b/integration-tests/langchain4j-agent/src/main/resources/application.properties
@@ -14,7 +14,7 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 ## ---------------------------------------------------------------------------
-quarkus.native.resources.includes=rag/*
+quarkus.native.resources.includes=rag/*,schemas/*
 quarkus.http.test-timeout=120S
 
 # This can be handy for detecting output from DefaultMcpClient npx process in case of eg. slow Windows machine.
diff --git a/integration-tests/langchain4j-agent/src/main/resources/schemas/test-pojo-schema.json b/integration-tests/langchain4j-agent/src/main/resources/schemas/test-pojo-schema.json
new file mode 100644
index 0000000000..4c10e239ed
--- /dev/null
+++ b/integration-tests/langchain4j-agent/src/main/resources/schemas/test-pojo-schema.json
@@ -0,0 +1,18 @@
+{
+  "type": "object",
+  "properties": {
+    "name": {
+      "type": "string",
+      "description": "The name of the person"
+    },
+    "description": {
+      "type": "string",
+      "description": "A description of the person"
+    }
+  },
+  "required": [
+    "name",
+    "description"
+  ],
+  "additionalProperties": false
+}
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 592c361897..8b83190a51 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
@@ -227,6 +227,73 @@ class Langchain4jAgentTest {
                         "toolWasInvoked", is(true));
     }
 
+    @Test
+    void structuredOutputWithOutputClass() {
+        RestAssured.given()
+                .body("Return an example JSON object about a person named '%s' with the fields name and description"
+                        .formatted(USER_JOHN))
+                .post("/langchain4j-agent/structured-output/class")
+                .then()
+                .statusCode(200)
+                .body(
+                        "name", is(USER_JOHN),
+                        "description", notNullValue());
+    }
+
+    @Test
+    void structuredOutputWithJsonSchema() {
+        RestAssured.given()
+                .body("Return an example JSON object about a person named '%s' with the fields name and description"
+                        .formatted(USER_JOHN))
+                .post("/langchain4j-agent/structured-output/json-schema")
+                .then()
+                .statusCode(200)
+                .body(
+                        "name", is(USER_JOHN),
+                        "description", notNullValue());
+    }
+
+    @Test
+    void autoProvisionSimple() {
+        RestAssured.given()
+                .body(TEST_USER_MESSAGE_SIMPLE)
+                .post("/langchain4j-agent/auto-provision/simple")
+                .then()
+                .statusCode(200)
+                .body(
+                        not(TEST_USER_MESSAGE_SIMPLE),
+                        containsString("Apache Camel"));
+    }
+
+    @Test
+    void autoProvisionWithMemory() {
+        String memoryId = "auto-provision-memory-1";
+
+        RestAssured.given()
+                .queryParam("memoryId", memoryId)
+                .body("Hello - my name is " + USER_ALICE)
+                .post("/langchain4j-agent/auto-provision/memory")
+                .then()
+                .statusCode(200);
+
+        RestAssured.given()
+                .queryParam("memoryId", memoryId)
+                .body("And my favorite color is " + USER_FAVORITE_COLOR)
+                .post("/langchain4j-agent/auto-provision/memory")
+                .then()
+                .statusCode(200);
+
+        RestAssured.given()
+                .queryParam("memoryId", memoryId)
+                .body("Now tell me about myself - what's my name and favorite color?")
+                .post("/langchain4j-agent/auto-provision/memory")
+                .then()
+                .statusCode(200)
+                .body(
+                        containsString(USER_ALICE),
+                        containsString(USER_FAVORITE_COLOR));
+    }
+
     @Test
     void agentWithMcpClient() {
         boolean isNodeJSInstalled = ConfigProvider.getConfig().getValue("nodejs.installed", boolean.class);
@@ -248,4 +315,17 @@ class Langchain4jAgentTest {
                 .and().body(containsStringIgnoringCase("successfully"))
                 .and().body(containsStringIgnoringCase("executed"));
     }
+
+    @Test
+    void mcpServerConfig() {
+        boolean isNodeJSInstalled = ConfigProvider.getConfig().getValue("nodejs.installed", boolean.class);
+        Assumptions.assumeTrue(isNodeJSInstalled, "Node.js is not installed");
+
+        RestAssured.given()
+                .body("Please list your available tools. You MUST respond using ONLY valid JSON with tool names as an array. DO NOT add explanations. DO NOT add comments. DO NOT wrap in markdown.")
+                .post("/langchain4j-agent/mcp/server-config")
+                .then()
+                .statusCode(200)
+                .body(".", containsInAnyOrder("add", "echo", "longRunningOperation"));
+    }
 }
diff --git a/integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-87f109c4-a6de-4770-bab4-8bbbdc5f6d4a.json b/integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-87f109c4-a6de-4770-bab4-8bbbdc5f6d4a.json
index a5c08aedf4..b2b3e8ee65 100644
--- a/integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-87f109c4-a6de-4770-bab4-8bbbdc5f6d4a.json
+++ b/integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-87f109c4-a6de-4770-bab4-8bbbdc5f6d4a.json
@@ -5,14 +5,14 @@
     "url" : "/api/chat",
     "method" : "POST",
     "bodyPatterns" : [ {
-      "equalToJson" : "{\n  \"model\" : \"orca-mini\",\n  \"messages\" : [ {\n    \"role\" : \"user\",\n    \"content\" : \"Return an example JSON object about a person named 'John Doe' with the fields name and description\"\n  } ],\n  \"options\" : {\n    \"temperature\" : 0.3,\n    \"stop\" : [ ]\n  },\n  \"stream\" : false,\n  \"tools\" : [ ]\n}",
+      "equalToJson" : "{\n  \"model\" : \"orca-mini\",\n  \"messages\" : [ {\n    \"role\" : \"user\",\n    \"content\" : \"Return an example JSON object about a person named 'John Doe' with the fields name and description\"\n  } ],\n  \"options\" : {\n    \"temperature\" : 0.3,\n    \"stop\" : [ ]\n  },\n  \"format\" : {\n    \"type\" : \"object\",\n    \"properties\" : {\n      \"name\" : {\n        \"type\" : \"string\",\n        \"description\" : \"The name of the person\"\n      },\ [...]
       "ignoreArrayOrder" : true,
       "ignoreExtraElements" : false
     } ]
   },
   "response" : {
     "status" : 200,
-    "body" : "{\"model\":\"orca-mini\",\"created_at\":\"2026-04-23T07:00:05.568298313Z\",\"message\":{\"role\":\"assistant\",\"content\":\" Sure, here's an example JSON object about John Doe with the fields name and description:\\n\\n```\\n{\\n \\\"name\\\": \\\"John Doe\\\",\\n \\\"description\\\": \\\"John Doe is a person who is highly intelligent and has a great sense of humor. He is also very hardworking and dedicated to his work.\\\"\\n}\\n```\"},\"done\":true,\"done_reason\":\"stop [...]
+    "body" : "{\"model\":\"orca-mini\",\"created_at\":\"2026-04-23T07:00:05.568298313Z\",\"message\":{\"role\":\"assistant\",\"content\":\"{\\\"name\\\": \\\"John Doe\\\", \\\"description\\\": \\\"John Doe is a person who is highly intelligent and has a great sense of humor. He is also very hardworking and dedicated to his work.\\\"}\"},\"done\":true,\"done_reason\":\"stop\",\"total_duration\":4074540384,\"load_duration\":17855473,\"prompt_eval_count\":60,\"prompt_eval_duration\":5507086 [...]
     "headers" : {
       "Date" : "Thu, 23 Apr 2026 07:00:05 GMT",
       "Content-Type" : "application/json; charset=utf-8"
@@ -21,4 +21,4 @@
   "uuid" : "87f109c4-a6de-4770-bab4-8bbbdc5f6d4a",
   "persistent" : true,
   "insertionIndex" : 15
-}
\ No newline at end of file
+}
diff --git a/integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-a1b2c3d4-e5f6-7890-abcd-ef1234567890.json b/integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-a1b2c3d4-e5f6-7890-abcd-ef1234567890.json
new file mode 100644
index 0000000000..0ba6b21f8b
--- /dev/null
+++ b/integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-a1b2c3d4-e5f6-7890-abcd-ef1234567890.json
@@ -0,0 +1,24 @@
+{
+  "id" : "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
+  "name" : "api_chat",
+  "request" : {
+    "url" : "/api/chat",
+    "method" : "POST",
+    "bodyPatterns" : [ {
+      "equalToJson" : "{\n  \"model\" : \"orca-mini\",\n  \"messages\" : [ {\n    \"role\" : \"user\",\n    \"content\" : \"Return an example JSON object about a person named 'John Doe' with the fields name and description\"\n  } ],\n  \"options\" : {\n    \"temperature\" : 0.3,\n    \"stop\" : [ ]\n  },\n  \"format\" : {\n    \"type\" : \"object\",\n    \"properties\" : {\n      \"name\" : {\n        \"type\" : \"string\"\n      },\n      \"description\" : {\n        \"type\" : \"string [...]
+      "ignoreArrayOrder" : true,
+      "ignoreExtraElements" : false
+    } ]
+  },
+  "response" : {
+    "status" : 200,
+    "body" : "{\"model\":\"orca-mini\",\"created_at\":\"2026-04-23T07:00:06.123456789Z\",\"message\":{\"role\":\"assistant\",\"content\":\"{\\\"name\\\": \\\"John Doe\\\", \\\"description\\\": \\\"John Doe is a person who is highly intelligent and has a great sense of humor. He is also very hardworking and dedicated to his work.\\\"}\"},\"done\":true,\"done_reason\":\"stop\",\"total_duration\":4074540384,\"load_duration\":17855473,\"prompt_eval_count\":60,\"prompt_eval_duration\":5507086 [...]
+    "headers" : {
+      "Date" : "Thu, 23 Apr 2026 07:00:06 GMT",
+      "Content-Type" : "application/json; charset=utf-8"
+    }
+  },
+  "uuid" : "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
+  "persistent" : true,
+  "insertionIndex" : 21
+}
diff --git a/integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-87f109c4-a6de-4770-bab4-8bbbdc5f6d4a.json b/integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-b2c3d4e5-f6a7-8901-bcde-f12345678901.json
similarity index 56%
copy from integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-87f109c4-a6de-4770-bab4-8bbbdc5f6d4a.json
copy to integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-b2c3d4e5-f6a7-8901-bcde-f12345678901.json
index a5c08aedf4..809298be16 100644
--- a/integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-87f109c4-a6de-4770-bab4-8bbbdc5f6d4a.json
+++ b/integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-b2c3d4e5-f6a7-8901-bcde-f12345678901.json
@@ -1,5 +1,5 @@
 {
-  "id" : "87f109c4-a6de-4770-bab4-8bbbdc5f6d4a",
+  "id" : "b2c3d4e5-f6a7-8901-bcde-f12345678901",
   "name" : "api_chat",
   "request" : {
     "url" : "/api/chat",
@@ -12,13 +12,13 @@
   },
   "response" : {
     "status" : 200,
-    "body" : "{\"model\":\"orca-mini\",\"created_at\":\"2026-04-23T07:00:05.568298313Z\",\"message\":{\"role\":\"assistant\",\"content\":\" Sure, here's an example JSON object about John Doe with the fields name and description:\\n\\n```\\n{\\n \\\"name\\\": \\\"John Doe\\\",\\n \\\"description\\\": \\\"John Doe is a person who is highly intelligent and has a great sense of humor. He is also very hardworking and dedicated to his work.\\\"\\n}\\n```\"},\"done\":true,\"done_reason\":\"stop [...]
+    "body" : "{\"model\":\"orca-mini\",\"created_at\":\"2026-04-23T07:00:05.568298313Z\",\"message\":{\"role\":\"assistant\",\"content\":\"{\\\"name\\\": \\\"John Doe\\\", \\\"description\\\": \\\"John Doe is a person who is highly intelligent and has a great sense of humor. He is also very hardworking and dedicated to his work.\\\"}\"},\"done\":true,\"done_reason\":\"stop\",\"total_duration\":4074540384,\"load_duration\":17855473,\"prompt_eval_count\":60,\"prompt_eval_duration\":5507086 [...]
     "headers" : {
       "Date" : "Thu, 23 Apr 2026 07:00:05 GMT",
       "Content-Type" : "application/json; charset=utf-8"
     }
   },
-  "uuid" : "87f109c4-a6de-4770-bab4-8bbbdc5f6d4a",
+  "uuid" : "b2c3d4e5-f6a7-8901-bcde-f12345678901",
   "persistent" : true,
-  "insertionIndex" : 15
-}
\ No newline at end of file
+  "insertionIndex" : 22
+}
diff --git a/integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-c85f8b72-57ab-4cce-9992-6114020e011a.json b/integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-c85f8b72-57ab-4cce-9992-6114020e011a.json
index fe7428d7db..127ae5730d 100644
--- a/integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-c85f8b72-57ab-4cce-9992-6114020e011a.json
+++ b/integration-tests/langchain4j-agent/src/test/resources/mappings/agent/api_chat-c85f8b72-57ab-4cce-9992-6114020e011a.json
@@ -21,4 +21,4 @@
   "uuid" : "c85f8b72-57ab-4cce-9992-6114020e011a",
   "persistent" : true,
   "insertionIndex" : 11
-}
\ No newline at end of file
+}


(camel-quarkus) 02/02: Fixes #8857. Tighten langchain4j agent MCP test coverage

Posted by gf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gansheer pushed a commit to branch feat/8857-improve-langchain4j-agent-test
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit 8f327e79e3aed0915b7757af135db465d6a83191
Author: Gaelle Fournier <ga...@gmail.com>
AuthorDate: Wed Aug 12 16:33:03 2026 +0200

    Fixes #8857. Tighten langchain4j agent MCP test coverage
    
    Always return a non-null agent configuration for the MCP server-config route and extend the MCP server-config integration test to verify both tool discovery and tool execution.
---
 .../component/langchain4j/agent/it/AgentProducers.java    | 15 ++++++---------
 .../langchain4j/agent/it/Langchain4jAgentTest.java        |  9 +++++++++
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/AgentProducers.java b/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/AgentProducers.java
index 38dd88a265..0b89fab433 100644
--- a/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/AgentProducers.java
+++ b/integration-tests/langchain4j-agent/src/main/java/org/apache/camel/quarkus/component/langchain4j/agent/it/AgentProducers.java
@@ -248,15 +248,12 @@ public class AgentProducers {
     @Produces
     @Identifier("agentConfigForMcp")
     AgentConfiguration agentConfigForMcp(@Identifier("granite4Model") ChatModel chatModel) {
-        if (isNodeJSInstaled) {
-            return new AgentConfiguration()
-                    .withChatModel(chatModel)
-                    .withMcpToolProviderFilter((mcpClient, toolSpecification) -> {
-                        String toolName = toolSpecification.name().toLowerCase();
-                        return toolName.contains("add") || toolName.contains("echo") || toolName.contains("long");
-                    });
-        }
-        return null;
+        return new AgentConfiguration()
+                .withChatModel(chatModel)
+                .withMcpToolProviderFilter((mcpClient, toolSpecification) -> {
+                    String toolName = toolSpecification.name().toLowerCase();
+                    return toolName.contains("add") || toolName.contains("echo") || toolName.contains("long");
+                });
     }
 
     @Produces
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 8b83190a51..69e362521d 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
@@ -327,5 +327,14 @@ class Langchain4jAgentTest {
                 .then()
                 .statusCode(200)
                 .body(".", containsInAnyOrder("add", "echo", "longRunningOperation"));
+
+        RestAssured.given()
+                .body("Use your available tools to perform a long running operation for 2 seconds with 2 steps. DO NOT use any markdown formatting in the response.")
+                .post("/langchain4j-agent/mcp/server-config")
+                .then()
+                .statusCode(200)
+                .body(containsStringIgnoringCase("operation"))
+                .and().body(containsStringIgnoringCase("successfully"))
+                .and().body(containsStringIgnoringCase("executed"));
     }
 }