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 <[email protected]> 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")); } }
