Andrea Cosentino created CAMEL-24609:
----------------------------------------

             Summary: camel-langchain4j-agent: the managed tool-execution 
executor is not recreated after a stop/start cycle
                 Key: CAMEL-24609
                 URL: https://issues.apache.org/jira/browse/CAMEL-24609
             Project: Camel
          Issue Type: Bug
          Components: camel-langchain4j-agent
            Reporter: Andrea Cosentino
            Assignee: Andrea Cosentino
             Fix For: 4.23.0


LangChain4jAgentProducer creates a Camel-managed thread pool in doInit 
(resolveExecuteToolsConcurrentlyExecutor) for the inline-agent + 
executeToolsConcurrently=true case with no user-supplied executor, and bakes it 
into the agent's AgentConfiguration (the agent is built once in doInit). doStop 
shuts that executor down (shutdownGraceful) and nulls the field, but doStart 
only rebuilds the materialized MCP clients - it does not recreate the executor, 
and the agent still references the terminated one.

After a route/producer stop then start, concurrent tool execution therefore 
fails with RejectedExecutionException. The MCP clients are handled correctly 
(rebuilt in doStart), so the executor is the odd one out.

Fix: tear the managed executor down in doShutdown instead of doStop so it lives 
for the agent's doInit-to-doShutdown lifetime (recreating it in doStart would 
not help, since the already-built agent holds the reference).

_Reported by an automated functional audit._



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to