This is an automated email from the ASF dual-hosted git repository.
fmariani 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 da585b16a1be camel-langchain4j-agent: Lookup the agentId in the
registry
da585b16a1be is described below
commit da585b16a1be8bed57aa4c98a4190c19ffe535b9
Author: Croway <[email protected]>
AuthorDate: Thu Dec 11 17:57:50 2025 +0100
camel-langchain4j-agent: Lookup the agentId in the registry
---
.../langchain4j/agent/LangChain4jAgentProducer.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
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 a11193191e5e..41fc57ea0001 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
@@ -43,12 +43,24 @@ public class LangChain4jAgentProducer extends
DefaultProducer {
private final LangChain4jAgentEndpoint endpoint;
private final ObjectMapper objectMapper = new ObjectMapper();
private AgentFactory agentFactory;
+ private Agent agent;
public LangChain4jAgentProducer(LangChain4jAgentEndpoint endpoint) {
super(endpoint);
this.endpoint = endpoint;
}
+ @Override
+ protected void doInit() throws Exception {
+ super.doInit();
+
+ if (endpoint.getConfiguration().getAgent() != null) {
+ agent = endpoint.getConfiguration().getAgent();
+ } else {
+ agent =
endpoint.getCamelContext().getRegistry().lookupByNameAndType(endpoint.getAgentId(),
Agent.class);
+ }
+ }
+
@Override
public void process(Exchange exchange) throws Exception {
Object messagePayload = exchange.getIn().getBody();
@@ -57,11 +69,8 @@ public class LangChain4jAgentProducer extends
DefaultProducer {
// tags for Camel Routes as Tools
String tags = endpoint.getConfiguration().getTags();
- Agent agent;
if (agentFactory != null) {
agent = agentFactory.createAgent(exchange);
- } else {
- agent = endpoint.getConfiguration().getAgent();
}
AiAgentBody<?> aiAgentBody = agent.processBody(messagePayload,
exchange);