Untitled conversation
- User
[BUG] Duplicate
activate_skilltool definition error when usingAgenticServices.createAgenticSystem()Describe the bug When creating an agentic system withAgenticServices.createAgenticSystem(), even with a single agent, the application throws anIllegalConfigurationException: Duplicated definition for tool: activate_skillduring execution, caused by multiple registrations of non-dynamicToolProviderinstances.Log and Stack trace
codeCaused by: dev.langchain4j.service.IllegalConfigurationException: Duplicated definition for tool: activate_skill at dev.langchain4j.service.tool.ToolService.addTools(ToolService.java:398) at dev.langchain4j.service.tool.ToolService.lambda$createContextFromStaticToolsAndProviders$0(ToolService.java:378) at java.base/java.lang.Iterable.forEach(Iterable.java:75) at dev.langchain4j.service.tool.ToolService.createContextFromStaticToolsAndProviders(ToolService.java:371) at dev.langchain4j.service.tool.ToolService.createContext(ToolService.java:338) at dev.langchain4j.service.DefaultAiServices$1.invoke(DefaultAiServices.java:260) at dev.langchain4j.service.DefaultAiServices$1.invoke(DefaultAiServices.java:154) at jdk.proxy2/jdk.proxy2.$Proxy5.test(Unknown Source) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ... 5 moreTo Reproduce
java - Assistant
Investigating duplicate
activate_skillregistration increateAgenticSystemby tracing tool provider registration in the agentic services code. - Assistant
Found the issue:
AgentBuildercallsconfigureAgentin its constructor, andcreateAgenticSystemcalls it again. Checking all instantiation paths to confirm the fix. - Assistant
Implementing the fix:
AgentBuilder's constructor callsconfigureAgent, andcreateAgenticSystemcalls it again—duplicating tool providers. - Assistant
Fixed the duplicate
activate_skillregistration bug.Root cause
configureAgent()was running twice for agents created viacreateAgenticSystem():- In the
AgentBuilderconstructor - Again in
createAgenticSystem()/createSubagent()
Each run invoked
@ToolProviderSupplieragain, so a newSkills.toolProvider()was added each time. For skills without scoped tools, those providers are non-dynamic and both registeractivate_skill, which triggersIllegalConfigurationException.agentBuilder(FooAgent.class).build()worked because it only configured once (constructor only).Fix
- Removed
configureAgent()from theAgentBuilderconstructor. - Moved declarative configuration into
AgenticServices.agentBuilder()(single call for the programmatic API). - Changed
createAgenticSystem()andcreateSubagent()to use directly, so runs only once with the correct .
- In the
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.