[
https://issues.apache.org/jira/browse/CAMEL-24609?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18111022#comment-18111022
]
Andrea Cosentino commented on CAMEL-24609:
------------------------------------------
Closing as Not A Problem after verification.
The reported failure (agent holding a terminated executor after a stop/start,
throwing RejectedExecutionException on concurrent tool execution) does not
actually occur. I added two runtime checks against a producer configured with
executeToolsConcurrently and two overlapping route tools:
* stop and restart of the whole CamelContext, then invoke the agent -> succeeds
(this case is already covered by
managedExecutorWorksAfterContextStopAndRestart);
* stop and restart of the individual route (route id), then invoke the agent ->
also succeeds.
Both pass on the current, unmodified code: Camel re-initializes the producer on
restart, so the managed executor referenced by the agent is always live. Moving
the teardown from doStop to doShutdown would only keep the executor threads
alive while the route is stopped, with no bug to fix. No code change is
warranted.
_Claude Code on behalf of oscerd_
> 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
> Priority: Major
> 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)