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
Now let me check the
ToolServicecode referenced in the stack trace and theSkillstool provider: - Assistant
Now let me verify the full edited file compiles logically and build the module:
- Assistant
Now build and test the module:
- Assistant
Compiles. Now let's find existing tests covering the declarative API and
ToolProviderSupplier: - Assistant
Now I'll write a regression test:
- Assistant
Test passes. Let me verify it actually reproduces the bug against the unfixed code:
- Assistant
Spotless can't run here (no
origin/mainref in this checkout), but the edits follow the surrounding code style. Final review of the change set: - Assistant
One small cleanup — my inserted methods split the two related chat-memory methods. Let me fix the ordering:
- Assistant
The fix is complete and verified.
Summary
Root cause:
AgentBuilder's constructor (AgentBuilder.java:141) already applies the declarative configuration by callingDeclarativeUtil.configureAgent.AgenticServices.createAgenticSystem(andcreateSubagentfor subagents) then calledconfigureAgentagain on the same builder. Overwriting setters masked this, but accumulating setters were applied twice:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.