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

zbendhiba pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new d054aef61b65 CAMEL-23649: camel-langchain4j-agent - allow Camel to 
create the agent internally from AgentConfiguration (#23767)
d054aef61b65 is described below

commit d054aef61b655346d7d4075d5e0c7ec7e5c1d328
Author: Zineb BENDHIBA <[email protected]>
AuthorDate: Fri Jun 5 09:38:44 2026 +0200

    CAMEL-23649: camel-langchain4j-agent - allow Camel to create the agent 
internally from AgentConfiguration (#23767)
    
    Co-authored-by: Claude Sonnet 4.6 (1M context) <[email protected]>
---
 .../catalog/components/langchain4j-agent.json      |  26 ++---
 .../agent/LangChain4jAgentComponentConfigurer.java |   8 +-
 .../LangChain4jAgentConfigurationConfigurer.java   |   6 ++
 .../agent/LangChain4jAgentEndpointConfigurer.java  |   8 +-
 .../agent/LangChain4jAgentEndpointUriFactory.java  |   3 +-
 .../langchain4j/agent/langchain4j-agent.json       |  26 ++---
 .../src/main/docs/langchain4j-agent-component.adoc |  39 ++++++++
 .../agent/LangChain4jAgentConfiguration.java       |  19 ++++
 .../agent/LangChain4jAgentProducer.java            |   8 ++
 .../LangChain4jAgentFromConfigurationIT.java       | 106 +++++++++++++++++++++
 .../Langchain4jAgentComponentBuilderFactory.java   |  20 ++++
 .../LangChain4jAgentEndpointBuilderFactory.java    |  36 +++++++
 12 files changed, 278 insertions(+), 27 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/langchain4j-agent.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/langchain4j-agent.json
index 97815437a1c9..fb06b6ebf076 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/langchain4j-agent.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/langchain4j-agent.json
@@ -25,13 +25,14 @@
   },
   "componentProperties": {
     "agent": { "index": 0, "kind": "property", "displayName": "Agent", 
"group": "producer", "label": "", "required": false, "type": "object", 
"javaType": "org.apache.camel.component.langchain4j.agent.api.Agent", 
"deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "The agent to use for the 
component" },
-    "agentFactory": { "index": 1, "kind": "property", "displayName": "Agent 
Factory", "group": "producer", "label": "", "required": false, "type": 
"object", "javaType": 
"org.apache.camel.component.langchain4j.agent.api.AgentFactory", "deprecated": 
false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "The agent factory to us 
[...]
-    "configuration": { "index": 2, "kind": "property", "displayName": 
"Configuration", "group": "producer", "label": "", "required": false, "type": 
"object", "javaType": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"deprecated": false, "autowired": false, "secret": false, "description": "The 
configuration" },
-    "lazyStartProducer": { "index": 3, "kind": "property", "displayName": 
"Lazy Start Producer", "group": "producer", "label": "producer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Whether the producer should be started lazy (on the first message). By 
starting lazy you can use this to allow CamelContext and routes to startup in 
situations where a producer may otherwise fail [...]
-    "tags": { "index": 4, "kind": "property", "displayName": "Tags", "group": 
"producer", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Tags for discovering and 
calling Camel route tools" },
-    "autowiredEnabled": { "index": 5, "kind": "property", "displayName": 
"Autowired Enabled", "group": "advanced", "label": "advanced", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Whether autowiring is enabled. This is used for automatic autowiring options 
(the option must be marked as autowired) by looking up in the registry to find 
if there is a single instance of matching t [...]
-    "mcpClients": { "index": 6, "kind": "property", "displayName": "Mcp 
Clients", "group": "advanced", "label": "advanced", "required": false, "type": 
"array", "javaType": "java.util.List<dev.langchain4j.mcp.client.McpClient>", 
"deprecated": false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Pre-built MCP (Model 
Context Protocol) client insta [...]
-    "mcpServer": { "index": 7, "kind": "property", "displayName": "Mcp 
Server", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", 
"prefix": "mcpServer.", "multiValue": true, "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "MCP server  [...]
+    "agentConfiguration": { "index": 1, "kind": "property", "displayName": 
"Agent Configuration", "group": "producer", "label": "", "required": false, 
"type": "object", "javaType": 
"org.apache.camel.component.langchain4j.agent.api.AgentConfiguration", 
"deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Agent [...]
+    "agentFactory": { "index": 2, "kind": "property", "displayName": "Agent 
Factory", "group": "producer", "label": "", "required": false, "type": 
"object", "javaType": 
"org.apache.camel.component.langchain4j.agent.api.AgentFactory", "deprecated": 
false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "The agent factory to us 
[...]
+    "configuration": { "index": 3, "kind": "property", "displayName": 
"Configuration", "group": "producer", "label": "", "required": false, "type": 
"object", "javaType": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"deprecated": false, "autowired": false, "secret": false, "description": "The 
configuration" },
+    "lazyStartProducer": { "index": 4, "kind": "property", "displayName": 
"Lazy Start Producer", "group": "producer", "label": "producer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Whether the producer should be started lazy (on the first message). By 
starting lazy you can use this to allow CamelContext and routes to startup in 
situations where a producer may otherwise fail [...]
+    "tags": { "index": 5, "kind": "property", "displayName": "Tags", "group": 
"producer", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Tags for discovering and 
calling Camel route tools" },
+    "autowiredEnabled": { "index": 6, "kind": "property", "displayName": 
"Autowired Enabled", "group": "advanced", "label": "advanced", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Whether autowiring is enabled. This is used for automatic autowiring options 
(the option must be marked as autowired) by looking up in the registry to find 
if there is a single instance of matching t [...]
+    "mcpClients": { "index": 7, "kind": "property", "displayName": "Mcp 
Clients", "group": "advanced", "label": "advanced", "required": false, "type": 
"array", "javaType": "java.util.List<dev.langchain4j.mcp.client.McpClient>", 
"deprecated": false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Pre-built MCP (Model 
Context Protocol) client insta [...]
+    "mcpServer": { "index": 8, "kind": "property", "displayName": "Mcp 
Server", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", 
"prefix": "mcpServer.", "multiValue": true, "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "MCP server  [...]
   },
   "headers": {
     "CamelLangChain4jAgentSystemMessage": { "index": 0, "kind": "header", 
"displayName": "", "group": "producer", "label": "", "required": false, 
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "The system prompt.", "constantName": 
"org.apache.camel.component.langchain4j.agent.api.Headers#SYSTEM_MESSAGE" },
@@ -44,10 +45,11 @@
   "properties": {
     "agentId": { "index": 0, "kind": "path", "displayName": "Agent Id", 
"group": "producer", "label": "", "required": true, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The Agent id" },
     "agent": { "index": 1, "kind": "parameter", "displayName": "Agent", 
"group": "producer", "label": "", "required": false, "type": "object", 
"javaType": "org.apache.camel.component.langchain4j.agent.api.Agent", 
"deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "The agent to use for the 
component" },
-    "agentFactory": { "index": 2, "kind": "parameter", "displayName": "Agent 
Factory", "group": "producer", "label": "", "required": false, "type": 
"object", "javaType": 
"org.apache.camel.component.langchain4j.agent.api.AgentFactory", "deprecated": 
false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "The agent factory to u 
[...]
-    "tags": { "index": 3, "kind": "parameter", "displayName": "Tags", "group": 
"producer", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Tags for discovering and 
calling Camel route tools" },
-    "lazyStartProducer": { "index": 4, "kind": "parameter", "displayName": 
"Lazy Start Producer", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the producer should be started 
lazy (on the first message). By starting lazy you can use this to allow 
CamelContext and routes to startup in situations where a produc [...]
-    "mcpClients": { "index": 5, "kind": "parameter", "displayName": "Mcp 
Clients", "group": "advanced", "label": "advanced", "required": false, "type": 
"array", "javaType": "java.util.List<dev.langchain4j.mcp.client.McpClient>", 
"deprecated": false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Pre-built MCP (Model 
Context Protocol) client inst [...]
-    "mcpServer": { "index": 6, "kind": "parameter", "displayName": "Mcp 
Server", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", 
"prefix": "mcpServer.", "multiValue": true, "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "MCP server [...]
+    "agentConfiguration": { "index": 2, "kind": "parameter", "displayName": 
"Agent Configuration", "group": "producer", "label": "", "required": false, 
"type": "object", "javaType": 
"org.apache.camel.component.langchain4j.agent.api.AgentConfiguration", 
"deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Agen [...]
+    "agentFactory": { "index": 3, "kind": "parameter", "displayName": "Agent 
Factory", "group": "producer", "label": "", "required": false, "type": 
"object", "javaType": 
"org.apache.camel.component.langchain4j.agent.api.AgentFactory", "deprecated": 
false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "The agent factory to u 
[...]
+    "tags": { "index": 4, "kind": "parameter", "displayName": "Tags", "group": 
"producer", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Tags for discovering and 
calling Camel route tools" },
+    "lazyStartProducer": { "index": 5, "kind": "parameter", "displayName": 
"Lazy Start Producer", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the producer should be started 
lazy (on the first message). By starting lazy you can use this to allow 
CamelContext and routes to startup in situations where a produc [...]
+    "mcpClients": { "index": 6, "kind": "parameter", "displayName": "Mcp 
Clients", "group": "advanced", "label": "advanced", "required": false, "type": 
"array", "javaType": "java.util.List<dev.langchain4j.mcp.client.McpClient>", 
"deprecated": false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Pre-built MCP (Model 
Context Protocol) client inst [...]
+    "mcpServer": { "index": 7, "kind": "parameter", "displayName": "Mcp 
Server", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", 
"prefix": "mcpServer.", "multiValue": true, "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "MCP server [...]
   }
 }
diff --git 
a/components/camel-ai/camel-langchain4j-agent/src/generated/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentComponentConfigurer.java
 
b/components/camel-ai/camel-langchain4j-agent/src/generated/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentComponentConfigurer.java
index 35edb4062ab1..0f476d995828 100644
--- 
a/components/camel-ai/camel-langchain4j-agent/src/generated/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentComponentConfigurer.java
+++ 
b/components/camel-ai/camel-langchain4j-agent/src/generated/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentComponentConfigurer.java
@@ -31,6 +31,8 @@ public class LangChain4jAgentComponentConfigurer extends 
PropertyConfigurerSuppo
         LangChain4jAgentComponent target = (LangChain4jAgentComponent) obj;
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "agent": 
getOrCreateConfiguration(target).setAgent(property(camelContext, 
org.apache.camel.component.langchain4j.agent.api.Agent.class, value)); return 
true;
+        case "agentconfiguration":
+        case "agentConfiguration": 
getOrCreateConfiguration(target).setAgentConfiguration(property(camelContext, 
org.apache.camel.component.langchain4j.agent.api.AgentConfiguration.class, 
value)); return true;
         case "agentfactory":
         case "agentFactory": 
getOrCreateConfiguration(target).setAgentFactory(property(camelContext, 
org.apache.camel.component.langchain4j.agent.api.AgentFactory.class, value)); 
return true;
         case "autowiredenabled":
@@ -49,13 +51,15 @@ public class LangChain4jAgentComponentConfigurer extends 
PropertyConfigurerSuppo
 
     @Override
     public String[] getAutowiredNames() {
-        return new String[]{"agent", "agentFactory"};
+        return new String[]{"agent", "agentConfiguration", "agentFactory"};
     }
 
     @Override
     public Class<?> getOptionType(String name, boolean ignoreCase) {
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "agent": return 
org.apache.camel.component.langchain4j.agent.api.Agent.class;
+        case "agentconfiguration":
+        case "agentConfiguration": return 
org.apache.camel.component.langchain4j.agent.api.AgentConfiguration.class;
         case "agentfactory":
         case "agentFactory": return 
org.apache.camel.component.langchain4j.agent.api.AgentFactory.class;
         case "autowiredenabled":
@@ -77,6 +81,8 @@ public class LangChain4jAgentComponentConfigurer extends 
PropertyConfigurerSuppo
         LangChain4jAgentComponent target = (LangChain4jAgentComponent) obj;
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "agent": return getOrCreateConfiguration(target).getAgent();
+        case "agentconfiguration":
+        case "agentConfiguration": return 
getOrCreateConfiguration(target).getAgentConfiguration();
         case "agentfactory":
         case "agentFactory": return 
getOrCreateConfiguration(target).getAgentFactory();
         case "autowiredenabled":
diff --git 
a/components/camel-ai/camel-langchain4j-agent/src/generated/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentConfigurationConfigurer.java
 
b/components/camel-ai/camel-langchain4j-agent/src/generated/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentConfigurationConfigurer.java
index 69a1f67aaede..8e4ac8585095 100644
--- 
a/components/camel-ai/camel-langchain4j-agent/src/generated/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentConfigurationConfigurer.java
+++ 
b/components/camel-ai/camel-langchain4j-agent/src/generated/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentConfigurationConfigurer.java
@@ -24,6 +24,8 @@ public class LangChain4jAgentConfigurationConfigurer extends 
org.apache.camel.su
         
org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration 
target = 
(org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration) 
obj;
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "agent": target.setAgent(property(camelContext, 
org.apache.camel.component.langchain4j.agent.api.Agent.class, value)); return 
true;
+        case "agentconfiguration":
+        case "agentConfiguration": 
target.setAgentConfiguration(property(camelContext, 
org.apache.camel.component.langchain4j.agent.api.AgentConfiguration.class, 
value)); return true;
         case "agentfactory":
         case "agentFactory": target.setAgentFactory(property(camelContext, 
org.apache.camel.component.langchain4j.agent.api.AgentFactory.class, value)); 
return true;
         case "mcpclients":
@@ -39,6 +41,8 @@ public class LangChain4jAgentConfigurationConfigurer extends 
org.apache.camel.su
     public Class<?> getOptionType(String name, boolean ignoreCase) {
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "agent": return 
org.apache.camel.component.langchain4j.agent.api.Agent.class;
+        case "agentconfiguration":
+        case "agentConfiguration": return 
org.apache.camel.component.langchain4j.agent.api.AgentConfiguration.class;
         case "agentfactory":
         case "agentFactory": return 
org.apache.camel.component.langchain4j.agent.api.AgentFactory.class;
         case "mcpclients":
@@ -55,6 +59,8 @@ public class LangChain4jAgentConfigurationConfigurer extends 
org.apache.camel.su
         
org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration 
target = 
(org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration) 
obj;
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "agent": return target.getAgent();
+        case "agentconfiguration":
+        case "agentConfiguration": return target.getAgentConfiguration();
         case "agentfactory":
         case "agentFactory": return target.getAgentFactory();
         case "mcpclients":
diff --git 
a/components/camel-ai/camel-langchain4j-agent/src/generated/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentEndpointConfigurer.java
 
b/components/camel-ai/camel-langchain4j-agent/src/generated/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentEndpointConfigurer.java
index ff73e3cd6af3..a90f44483690 100644
--- 
a/components/camel-ai/camel-langchain4j-agent/src/generated/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentEndpointConfigurer.java
+++ 
b/components/camel-ai/camel-langchain4j-agent/src/generated/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentEndpointConfigurer.java
@@ -24,6 +24,8 @@ public class LangChain4jAgentEndpointConfigurer extends 
PropertyConfigurerSuppor
         LangChain4jAgentEndpoint target = (LangChain4jAgentEndpoint) obj;
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "agent": 
target.getConfiguration().setAgent(property(camelContext, 
org.apache.camel.component.langchain4j.agent.api.Agent.class, value)); return 
true;
+        case "agentconfiguration":
+        case "agentConfiguration": 
target.getConfiguration().setAgentConfiguration(property(camelContext, 
org.apache.camel.component.langchain4j.agent.api.AgentConfiguration.class, 
value)); return true;
         case "agentfactory":
         case "agentFactory": 
target.getConfiguration().setAgentFactory(property(camelContext, 
org.apache.camel.component.langchain4j.agent.api.AgentFactory.class, value)); 
return true;
         case "lazystartproducer":
@@ -39,13 +41,15 @@ public class LangChain4jAgentEndpointConfigurer extends 
PropertyConfigurerSuppor
 
     @Override
     public String[] getAutowiredNames() {
-        return new String[]{"agent", "agentFactory"};
+        return new String[]{"agent", "agentConfiguration", "agentFactory"};
     }
 
     @Override
     public Class<?> getOptionType(String name, boolean ignoreCase) {
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "agent": return 
org.apache.camel.component.langchain4j.agent.api.Agent.class;
+        case "agentconfiguration":
+        case "agentConfiguration": return 
org.apache.camel.component.langchain4j.agent.api.AgentConfiguration.class;
         case "agentfactory":
         case "agentFactory": return 
org.apache.camel.component.langchain4j.agent.api.AgentFactory.class;
         case "lazystartproducer":
@@ -64,6 +68,8 @@ public class LangChain4jAgentEndpointConfigurer extends 
PropertyConfigurerSuppor
         LangChain4jAgentEndpoint target = (LangChain4jAgentEndpoint) obj;
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "agent": return target.getConfiguration().getAgent();
+        case "agentconfiguration":
+        case "agentConfiguration": return 
target.getConfiguration().getAgentConfiguration();
         case "agentfactory":
         case "agentFactory": return 
target.getConfiguration().getAgentFactory();
         case "lazystartproducer":
diff --git 
a/components/camel-ai/camel-langchain4j-agent/src/generated/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentEndpointUriFactory.java
 
b/components/camel-ai/camel-langchain4j-agent/src/generated/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentEndpointUriFactory.java
index 79bb63bb4a47..d6ce55a99b94 100644
--- 
a/components/camel-ai/camel-langchain4j-agent/src/generated/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentEndpointUriFactory.java
+++ 
b/components/camel-ai/camel-langchain4j-agent/src/generated/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentEndpointUriFactory.java
@@ -24,8 +24,9 @@ public class LangChain4jAgentEndpointUriFactory extends 
org.apache.camel.support
     private static final Set<String> ENDPOINT_IDENTITY_PROPERTY_NAMES;
     private static final Map<String, String> MULTI_VALUE_PREFIXES;
     static {
-        Set<String> props = new HashSet<>(7);
+        Set<String> props = new HashSet<>(8);
         props.add("agent");
+        props.add("agentConfiguration");
         props.add("agentFactory");
         props.add("agentId");
         props.add("lazyStartProducer");
diff --git 
a/components/camel-ai/camel-langchain4j-agent/src/generated/resources/META-INF/org/apache/camel/component/langchain4j/agent/langchain4j-agent.json
 
b/components/camel-ai/camel-langchain4j-agent/src/generated/resources/META-INF/org/apache/camel/component/langchain4j/agent/langchain4j-agent.json
index 97815437a1c9..fb06b6ebf076 100644
--- 
a/components/camel-ai/camel-langchain4j-agent/src/generated/resources/META-INF/org/apache/camel/component/langchain4j/agent/langchain4j-agent.json
+++ 
b/components/camel-ai/camel-langchain4j-agent/src/generated/resources/META-INF/org/apache/camel/component/langchain4j/agent/langchain4j-agent.json
@@ -25,13 +25,14 @@
   },
   "componentProperties": {
     "agent": { "index": 0, "kind": "property", "displayName": "Agent", 
"group": "producer", "label": "", "required": false, "type": "object", 
"javaType": "org.apache.camel.component.langchain4j.agent.api.Agent", 
"deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "The agent to use for the 
component" },
-    "agentFactory": { "index": 1, "kind": "property", "displayName": "Agent 
Factory", "group": "producer", "label": "", "required": false, "type": 
"object", "javaType": 
"org.apache.camel.component.langchain4j.agent.api.AgentFactory", "deprecated": 
false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "The agent factory to us 
[...]
-    "configuration": { "index": 2, "kind": "property", "displayName": 
"Configuration", "group": "producer", "label": "", "required": false, "type": 
"object", "javaType": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"deprecated": false, "autowired": false, "secret": false, "description": "The 
configuration" },
-    "lazyStartProducer": { "index": 3, "kind": "property", "displayName": 
"Lazy Start Producer", "group": "producer", "label": "producer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Whether the producer should be started lazy (on the first message). By 
starting lazy you can use this to allow CamelContext and routes to startup in 
situations where a producer may otherwise fail [...]
-    "tags": { "index": 4, "kind": "property", "displayName": "Tags", "group": 
"producer", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Tags for discovering and 
calling Camel route tools" },
-    "autowiredEnabled": { "index": 5, "kind": "property", "displayName": 
"Autowired Enabled", "group": "advanced", "label": "advanced", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Whether autowiring is enabled. This is used for automatic autowiring options 
(the option must be marked as autowired) by looking up in the registry to find 
if there is a single instance of matching t [...]
-    "mcpClients": { "index": 6, "kind": "property", "displayName": "Mcp 
Clients", "group": "advanced", "label": "advanced", "required": false, "type": 
"array", "javaType": "java.util.List<dev.langchain4j.mcp.client.McpClient>", 
"deprecated": false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Pre-built MCP (Model 
Context Protocol) client insta [...]
-    "mcpServer": { "index": 7, "kind": "property", "displayName": "Mcp 
Server", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", 
"prefix": "mcpServer.", "multiValue": true, "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "MCP server  [...]
+    "agentConfiguration": { "index": 1, "kind": "property", "displayName": 
"Agent Configuration", "group": "producer", "label": "", "required": false, 
"type": "object", "javaType": 
"org.apache.camel.component.langchain4j.agent.api.AgentConfiguration", 
"deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Agent [...]
+    "agentFactory": { "index": 2, "kind": "property", "displayName": "Agent 
Factory", "group": "producer", "label": "", "required": false, "type": 
"object", "javaType": 
"org.apache.camel.component.langchain4j.agent.api.AgentFactory", "deprecated": 
false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "The agent factory to us 
[...]
+    "configuration": { "index": 3, "kind": "property", "displayName": 
"Configuration", "group": "producer", "label": "", "required": false, "type": 
"object", "javaType": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"deprecated": false, "autowired": false, "secret": false, "description": "The 
configuration" },
+    "lazyStartProducer": { "index": 4, "kind": "property", "displayName": 
"Lazy Start Producer", "group": "producer", "label": "producer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Whether the producer should be started lazy (on the first message). By 
starting lazy you can use this to allow CamelContext and routes to startup in 
situations where a producer may otherwise fail [...]
+    "tags": { "index": 5, "kind": "property", "displayName": "Tags", "group": 
"producer", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Tags for discovering and 
calling Camel route tools" },
+    "autowiredEnabled": { "index": 6, "kind": "property", "displayName": 
"Autowired Enabled", "group": "advanced", "label": "advanced", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Whether autowiring is enabled. This is used for automatic autowiring options 
(the option must be marked as autowired) by looking up in the registry to find 
if there is a single instance of matching t [...]
+    "mcpClients": { "index": 7, "kind": "property", "displayName": "Mcp 
Clients", "group": "advanced", "label": "advanced", "required": false, "type": 
"array", "javaType": "java.util.List<dev.langchain4j.mcp.client.McpClient>", 
"deprecated": false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Pre-built MCP (Model 
Context Protocol) client insta [...]
+    "mcpServer": { "index": 8, "kind": "property", "displayName": "Mcp 
Server", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", 
"prefix": "mcpServer.", "multiValue": true, "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "MCP server  [...]
   },
   "headers": {
     "CamelLangChain4jAgentSystemMessage": { "index": 0, "kind": "header", 
"displayName": "", "group": "producer", "label": "", "required": false, 
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "The system prompt.", "constantName": 
"org.apache.camel.component.langchain4j.agent.api.Headers#SYSTEM_MESSAGE" },
@@ -44,10 +45,11 @@
   "properties": {
     "agentId": { "index": 0, "kind": "path", "displayName": "Agent Id", 
"group": "producer", "label": "", "required": true, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The Agent id" },
     "agent": { "index": 1, "kind": "parameter", "displayName": "Agent", 
"group": "producer", "label": "", "required": false, "type": "object", 
"javaType": "org.apache.camel.component.langchain4j.agent.api.Agent", 
"deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "The agent to use for the 
component" },
-    "agentFactory": { "index": 2, "kind": "parameter", "displayName": "Agent 
Factory", "group": "producer", "label": "", "required": false, "type": 
"object", "javaType": 
"org.apache.camel.component.langchain4j.agent.api.AgentFactory", "deprecated": 
false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "The agent factory to u 
[...]
-    "tags": { "index": 3, "kind": "parameter", "displayName": "Tags", "group": 
"producer", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Tags for discovering and 
calling Camel route tools" },
-    "lazyStartProducer": { "index": 4, "kind": "parameter", "displayName": 
"Lazy Start Producer", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the producer should be started 
lazy (on the first message). By starting lazy you can use this to allow 
CamelContext and routes to startup in situations where a produc [...]
-    "mcpClients": { "index": 5, "kind": "parameter", "displayName": "Mcp 
Clients", "group": "advanced", "label": "advanced", "required": false, "type": 
"array", "javaType": "java.util.List<dev.langchain4j.mcp.client.McpClient>", 
"deprecated": false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Pre-built MCP (Model 
Context Protocol) client inst [...]
-    "mcpServer": { "index": 6, "kind": "parameter", "displayName": "Mcp 
Server", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", 
"prefix": "mcpServer.", "multiValue": true, "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "MCP server [...]
+    "agentConfiguration": { "index": 2, "kind": "parameter", "displayName": 
"Agent Configuration", "group": "producer", "label": "", "required": false, 
"type": "object", "javaType": 
"org.apache.camel.component.langchain4j.agent.api.AgentConfiguration", 
"deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Agen [...]
+    "agentFactory": { "index": 3, "kind": "parameter", "displayName": "Agent 
Factory", "group": "producer", "label": "", "required": false, "type": 
"object", "javaType": 
"org.apache.camel.component.langchain4j.agent.api.AgentFactory", "deprecated": 
false, "deprecationNote": "", "autowired": true, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "The agent factory to u 
[...]
+    "tags": { "index": 4, "kind": "parameter", "displayName": "Tags", "group": 
"producer", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Tags for discovering and 
calling Camel route tools" },
+    "lazyStartProducer": { "index": 5, "kind": "parameter", "displayName": 
"Lazy Start Producer", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the producer should be started 
lazy (on the first message). By starting lazy you can use this to allow 
CamelContext and routes to startup in situations where a produc [...]
+    "mcpClients": { "index": 6, "kind": "parameter", "displayName": "Mcp 
Clients", "group": "advanced", "label": "advanced", "required": false, "type": 
"array", "javaType": "java.util.List<dev.langchain4j.mcp.client.McpClient>", 
"deprecated": false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "Pre-built MCP (Model 
Context Protocol) client inst [...]
+    "mcpServer": { "index": 7, "kind": "parameter", "displayName": "Mcp 
Server", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", 
"prefix": "mcpServer.", "multiValue": true, "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration", 
"configurationField": "configuration", "description": "MCP server [...]
   }
 }
diff --git 
a/components/camel-ai/camel-langchain4j-agent/src/main/docs/langchain4j-agent-component.adoc
 
b/components/camel-ai/camel-langchain4j-agent/src/main/docs/langchain4j-agent-component.adoc
index bb6902b30a4e..c8fe9af8ba1a 100644
--- 
a/components/camel-ai/camel-langchain4j-agent/src/main/docs/langchain4j-agent-component.adoc
+++ 
b/components/camel-ai/camel-langchain4j-agent/src/main/docs/langchain4j-agent-component.adoc
@@ -215,6 +215,45 @@ Add the `camel-langchain4j-agent-api` dependency to access 
the Agent API classes
 ----
 ====
 
+=== Using AgentConfiguration Directly
+
+Instead of manually instantiating `AgentWithoutMemory` or `AgentWithMemory`, 
you can register an `AgentConfiguration` bean and let Camel create the right 
agent implementation automatically. Camel creates an `AgentWithMemory` when a 
`ChatMemoryProvider` is present, or an `AgentWithoutMemory` otherwise.
+
+==== Stateless agent
+
+[source,java]
+----
+AgentConfiguration config = new AgentConfiguration()
+    .withChatModel(chatModel);
+
+context.getRegistry().bind("myConfig", config);
+
+from("direct:chat")
+    .to("langchain4j-agent:assistant?agentConfiguration=#myConfig");
+----
+
+==== Stateful agent (with memory)
+
+[source,java]
+----
+ChatMemoryProvider memoryProvider = memoryId -> 
MessageWindowChatMemory.builder()
+    .id(memoryId)
+    .maxMessages(10)
+    .chatMemoryStore(persistentStore)
+    .build();
+
+AgentConfiguration config = new AgentConfiguration()
+    .withChatModel(chatModel)
+    .withChatMemoryProvider(memoryProvider);
+
+context.getRegistry().bind("myConfig", config);
+
+from("direct:chat")
+    .to("langchain4j-agent:assistant?agentConfiguration=#myConfig");
+----
+
+If an `agentFactory` is also configured on the endpoint, the factory takes 
precedence over `agentConfiguration`.
+
 === Basic Chat with only a userMessage
 
 For simple chat interactions, you can use an agent without memory.
diff --git 
a/components/camel-ai/camel-langchain4j-agent/src/main/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentConfiguration.java
 
b/components/camel-ai/camel-langchain4j-agent/src/main/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentConfiguration.java
index 5379129df3f2..987385b6772a 100644
--- 
a/components/camel-ai/camel-langchain4j-agent/src/main/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentConfiguration.java
+++ 
b/components/camel-ai/camel-langchain4j-agent/src/main/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentConfiguration.java
@@ -22,6 +22,7 @@ import java.util.Map;
 import dev.langchain4j.mcp.client.McpClient;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.component.langchain4j.agent.api.Agent;
+import org.apache.camel.component.langchain4j.agent.api.AgentConfiguration;
 import org.apache.camel.component.langchain4j.agent.api.AgentFactory;
 import org.apache.camel.spi.Configurer;
 import org.apache.camel.spi.Metadata;
@@ -40,6 +41,13 @@ public class LangChain4jAgentConfiguration implements 
Cloneable {
     @Metadata(autowired = true)
     private AgentFactory agentFactory;
 
+    @UriParam(description = "AgentConfiguration used by Camel to create the 
agent internally."
+                            + " When set, Camel creates an AgentWithMemory if 
a ChatMemoryProvider is configured,"
+                            + " otherwise an AgentWithoutMemory."
+                            + " If an agentFactory is also configured, the 
factory takes precedence.")
+    @Metadata(autowired = true)
+    private AgentConfiguration agentConfiguration;
+
     @UriParam(description = "Tags for discovering and calling Camel route 
tools")
     private String tags;
 
@@ -107,6 +115,17 @@ public class LangChain4jAgentConfiguration implements 
Cloneable {
         this.agentFactory = agentFactory;
     }
 
+    /**
+     * AgentConfiguration used by Camel to create the agent internally.
+     */
+    public AgentConfiguration getAgentConfiguration() {
+        return agentConfiguration;
+    }
+
+    public void setAgentConfiguration(AgentConfiguration agentConfiguration) {
+        this.agentConfiguration = agentConfiguration;
+    }
+
     /**
      * Pre-built MCP client instances for external tool integration
      *
diff --git 
a/components/camel-ai/camel-langchain4j-agent/src/main/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentProducer.java
 
b/components/camel-ai/camel-langchain4j-agent/src/main/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentProducer.java
index ae977d6e5bf3..ac40b153ceee 100644
--- 
a/components/camel-ai/camel-langchain4j-agent/src/main/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentProducer.java
+++ 
b/components/camel-ai/camel-langchain4j-agent/src/main/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentProducer.java
@@ -32,7 +32,10 @@ import dev.langchain4j.service.tool.ToolProviderRequest;
 import dev.langchain4j.service.tool.ToolProviderResult;
 import org.apache.camel.Exchange;
 import org.apache.camel.component.langchain4j.agent.api.Agent;
+import org.apache.camel.component.langchain4j.agent.api.AgentConfiguration;
 import org.apache.camel.component.langchain4j.agent.api.AgentFactory;
+import org.apache.camel.component.langchain4j.agent.api.AgentWithMemory;
+import org.apache.camel.component.langchain4j.agent.api.AgentWithoutMemory;
 import org.apache.camel.component.langchain4j.agent.api.AiAgentBody;
 import org.apache.camel.component.langchain4j.agent.api.CompositeToolProvider;
 import org.apache.camel.component.langchain4j.agent.api.Headers;
@@ -63,6 +66,11 @@ public class LangChain4jAgentProducer extends 
DefaultProducer {
 
         if (endpoint.getConfiguration().getAgent() != null) {
             agent = endpoint.getConfiguration().getAgent();
+        } else if (endpoint.getConfiguration().getAgentConfiguration() != 
null) {
+            AgentConfiguration agentConfiguration = 
endpoint.getConfiguration().getAgentConfiguration();
+            agent = agentConfiguration.getChatMemoryProvider() != null
+                    ? new AgentWithMemory(agentConfiguration)
+                    : new AgentWithoutMemory(agentConfiguration);
         } else {
             agent = 
endpoint.getCamelContext().getRegistry().lookupByNameAndType(endpoint.getAgentId(),
 Agent.class);
         }
diff --git 
a/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jAgentFromConfigurationIT.java
 
b/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jAgentFromConfigurationIT.java
new file mode 100644
index 000000000000..5b525780bbe6
--- /dev/null
+++ 
b/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jAgentFromConfigurationIT.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.langchain4j.agent.integration;
+
+import dev.langchain4j.memory.chat.ChatMemoryProvider;
+import dev.langchain4j.memory.chat.MessageWindowChatMemory;
+import dev.langchain4j.model.chat.ChatModel;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.langchain4j.agent.api.AgentConfiguration;
+import org.apache.camel.component.langchain4j.agent.api.AiAgentBody;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.ollama.services.OllamaService;
+import org.apache.camel.test.infra.ollama.services.OllamaServiceFactory;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+/**
+ * Verifies that Camel creates the agent internally from an AgentConfiguration 
bean, so users no longer need to
+ * instantiate AgentWithoutMemory or AgentWithMemory themselves.
+ */
+@DisabledIfSystemProperty(named = "ci.env.name", matches = ".*", 
disabledReason = "Requires too much network resources")
+public class LangChain4jAgentFromConfigurationIT extends CamelTestSupport {
+
+    private static final String TEST_USER_MESSAGE = "What is Apache Camel?";
+
+    @RegisterExtension
+    static OllamaService OLLAMA = 
OllamaServiceFactory.createSingletonService();
+
+    @Test
+    void testAgentCreatedFromConfiguration() throws Exception {
+        MockEndpoint mockEndpoint = getMockEndpoint("mock:response");
+        mockEndpoint.expectedMessageCount(1);
+
+        String response = template.requestBody("direct:from-config", 
TEST_USER_MESSAGE, String.class);
+
+        mockEndpoint.assertIsSatisfied();
+        assertNotNull(response);
+        assertFalse(response.isBlank());
+    }
+
+    @Test
+    void testAgentCreatedFromConfigurationWithMemory() throws Exception {
+        MockEndpoint mockEndpoint = getMockEndpoint("mock:response-memory");
+        mockEndpoint.expectedMessageCount(1);
+
+        AiAgentBody body = new AiAgentBody(TEST_USER_MESSAGE, null, 
"test-session");
+        String response = 
template.requestBody("direct:from-config-with-memory", body, String.class);
+
+        mockEndpoint.assertIsSatisfied();
+        assertNotNull(response);
+        assertFalse(response.isBlank());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        ChatModel chatModel = ModelHelper.loadChatModel(OLLAMA);
+
+        AgentConfiguration agentConfiguration = new AgentConfiguration()
+                .withChatModel(chatModel);
+
+        context.getRegistry().bind("myAgentConfig", agentConfiguration);
+
+        ChatMemoryProvider memoryProvider = memoryId -> 
MessageWindowChatMemory.builder()
+                .id(memoryId)
+                .maxMessages(10)
+                .build();
+
+        AgentConfiguration agentConfigWithMemory = new AgentConfiguration()
+                .withChatModel(chatModel)
+                .withChatMemoryProvider(memoryProvider);
+
+        context.getRegistry().bind("myAgentConfigWithMemory", 
agentConfigWithMemory);
+
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:from-config")
+                        
.to("langchain4j-agent:test?agentConfiguration=#myAgentConfig")
+                        .to("mock:response");
+
+                from("direct:from-config-with-memory")
+                        
.to("langchain4j-agent:test-memory?agentConfiguration=#myAgentConfigWithMemory")
+                        .to("mock:response-memory");
+            }
+        };
+    }
+}
diff --git 
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Langchain4jAgentComponentBuilderFactory.java
 
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Langchain4jAgentComponentBuilderFactory.java
index d53ca774315c..2460f65744ed 100644
--- 
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Langchain4jAgentComponentBuilderFactory.java
+++ 
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Langchain4jAgentComponentBuilderFactory.java
@@ -66,6 +66,25 @@ public interface Langchain4jAgentComponentBuilderFactory {
             return this;
         }
     
+        /**
+         * AgentConfiguration used by Camel to create the agent internally. 
When
+         * set, Camel creates an AgentWithMemory if a ChatMemoryProvider is
+         * configured, otherwise an AgentWithoutMemory. If an agentFactory is
+         * also configured, the factory takes precedence.
+         * 
+         * The option is a:
+         * 
&lt;code&gt;org.apache.camel.component.langchain4j.agent.api.AgentConfiguration&lt;/code&gt;
 type.
+         * 
+         * Group: producer
+         * 
+         * @param agentConfiguration the value to set
+         * @return the dsl builder
+         */
+        default Langchain4jAgentComponentBuilder 
agentConfiguration(org.apache.camel.component.langchain4j.agent.api.AgentConfiguration
 agentConfiguration) {
+            doSetProperty("agentConfiguration", agentConfiguration);
+            return this;
+        }
+    
         /**
          * The agent factory to use for creating agents if no Agent is 
provided.
          * 
@@ -221,6 +240,7 @@ public interface Langchain4jAgentComponentBuilderFactory {
                 Object value) {
             switch (name) {
             case "agent": getOrCreateConfiguration((LangChain4jAgentComponent) 
component).setAgent((org.apache.camel.component.langchain4j.agent.api.Agent) 
value); return true;
+            case "agentConfiguration": 
getOrCreateConfiguration((LangChain4jAgentComponent) 
component).setAgentConfiguration((org.apache.camel.component.langchain4j.agent.api.AgentConfiguration)
 value); return true;
             case "agentFactory": 
getOrCreateConfiguration((LangChain4jAgentComponent) 
component).setAgentFactory((org.apache.camel.component.langchain4j.agent.api.AgentFactory)
 value); return true;
             case "configuration": ((LangChain4jAgentComponent) 
component).setConfiguration((org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration)
 value); return true;
             case "lazyStartProducer": ((LangChain4jAgentComponent) 
component).setLazyStartProducer((boolean) value); return true;
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/LangChain4jAgentEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/LangChain4jAgentEndpointBuilderFactory.java
index 7152efe820e3..eafc10a8233e 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/LangChain4jAgentEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/LangChain4jAgentEndpointBuilderFactory.java
@@ -76,6 +76,42 @@ public interface LangChain4jAgentEndpointBuilderFactory {
             doSetProperty("agent", agent);
             return this;
         }
+        /**
+         * AgentConfiguration used by Camel to create the agent internally. 
When
+         * set, Camel creates an AgentWithMemory if a ChatMemoryProvider is
+         * configured, otherwise an AgentWithoutMemory. If an agentFactory is
+         * also configured, the factory takes precedence.
+         * 
+         * The option is a:
+         * 
<code>org.apache.camel.component.langchain4j.agent.api.AgentConfiguration</code>
 type.
+         * 
+         * Group: producer
+         * 
+         * @param agentConfiguration the value to set
+         * @return the dsl builder
+         */
+        default LangChain4jAgentEndpointBuilder 
agentConfiguration(org.apache.camel.component.langchain4j.agent.api.AgentConfiguration
 agentConfiguration) {
+            doSetProperty("agentConfiguration", agentConfiguration);
+            return this;
+        }
+        /**
+         * AgentConfiguration used by Camel to create the agent internally. 
When
+         * set, Camel creates an AgentWithMemory if a ChatMemoryProvider is
+         * configured, otherwise an AgentWithoutMemory. If an agentFactory is
+         * also configured, the factory takes precedence.
+         * 
+         * The option will be converted to a
+         * 
<code>org.apache.camel.component.langchain4j.agent.api.AgentConfiguration</code>
 type.
+         * 
+         * Group: producer
+         * 
+         * @param agentConfiguration the value to set
+         * @return the dsl builder
+         */
+        default LangChain4jAgentEndpointBuilder agentConfiguration(String 
agentConfiguration) {
+            doSetProperty("agentConfiguration", agentConfiguration);
+            return this;
+        }
         /**
          * The agent factory to use for creating agents if no Agent is 
provided.
          * 

Reply via email to