ISSUE DESCRIPTION [BUG] Duplicate activate_skill tool definition error when using…
- User
ISSUE DESCRIPTION
[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
Caused 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
public class Main { public static void main(String[] args) { var result=AgenticServices.createAgenticSystem(FooAgent.class).test(); // var result=AgenticServices.agentBuilder(FooAgent.class).build().test(); System.out.println(result); } public interface FooAgent { @Agent @UserMessage("Hello") String test(); @ToolProviderSupplier static ToolProvider testTool() { return Skills.builder() .skills(Skill.builder().name("test").description("test").content("test").build()) .build().toolProvider(); } @ChatModelSupplier static ChatModel chatModel() { return OpenAiChatModel.builder() .baseUrl("http://192.168.31.32:8000/v1") .apiKey("none") .modelName("qwen3.6") .logRequests(true) .logResponses(true) .build(); } } }Expected behavior The agentic system should run successfully, properly deduplicating tools (including the built-in
activate_skilltool) when registering non-dynamicToolProviderinstances.Please complete the following information:
- Assistant
I'll start by exploring the repository structure and locating the relevant code for
createAgenticSystemand tool registration. - Assistant
Next I'll inspect
createAgenticSystemand how skills/tool providers are registered. - Assistant
rg is not available, let me use grep instead.
- Assistant
Let me open the AgenticServices.java file around createAgenticSystem and explore related code.
- Assistant
I'll locate where tool providers get configured for agents.
- Assistant
Double registration looks likely —
configureAgentmay run in the builder constructor and again increateAgenticSystem. Checking that path. - Assistant
Confirming double configuration — I'll inspect
agentBuilderfactories and related tests for the intended fix. - Assistant
Checking recent history and how tools accumulate on the builder.
- Assistant
Inspecting how
toolsis set and whether other list fields suffer the same double-add. - Assistant
Checking all call sites that construct
AgentBuilderor callconfigureAgent. - Assistant
Inspecting
ToolServicefor how non-dynamic providers are merged — that matches the stack trace. - Assistant
Checking direct
AgentBuilderconstruction usages in tests and the full source tree. - Assistant
Reading chat-model configuration on AgentBuilder to design a safe one-time apply path.
- Assistant
Root cause:
configureAgentruns in theAgentBuilderconstructor and again increateAgenticSystem/createSubagent, soToolProviderSupplieris invoked twice and registers duplicate non-dynamic tools. I'll configure only once. - Assistant
Implementing a constructor overload that skips declarative config, and using it from
createAgenticSystemandcreateSubagent. - Assistant
Updating
AgenticServicesto construct the builder without declarative configuration so it is applied only once. - Assistant
I need to update both createAgenticSystem and createSubagent.
- Assistant
Now fix createSubagent as well.
- Assistant
Need to navigate to the line first.
- Assistant
Now I can edit createSubagent.
- Assistant
Checking imports and writing a reproduction test.
- Assistant
I'll write a temporary unit test with a custom non-dynamic ToolProvider to verify the fix without the skills module.
- Assistant
I'll use the existing stub chat model pattern to craft a temporary reproduction.
- Assistant
Creating a temporary test that would fail on the old code and pass with our fix.
- Assistant
Building the required modules, then compiling and running the reproduction.
- Assistant
Setting HOME and retrying the build.
- Assistant
Build succeeded. Compiling and running the reproduction next.
- Assistant
ChatModel isn't a functional interface — updating the reproduction accordingly.
- Assistant
Confirming the fix works. Verifying the old code still fails by temporarily reverting.
- Assistant
Reproduction confirms the fix. Running unit tests that don't need an LLM next.
- Assistant
Rerunning tests without quiet mode for clearer output.
- Assistant
Making the boolean constructor private and adding an internal factory to keep the public API clean.
- Assistant
I'll switch to a private constructor plus a clear static factory so we don't widen the public API surface.
- Assistant
Duplicate constructor body left behind — cleaning it up.
- Assistant
I need to remove lines 179-194 which are orphaned duplicates, and also fix the typo in javadoc
@ToolProviderSupplier}/ - Assistant
Fixing typos introduced earlier.
- Assistant
Still need to fix the enigmatic character 贤0
- Assistant
Updating AgenticServices to use the factory method.
- Assistant
Need to goto the lines first or use sed.
- Assistant
I'll replace both occurrences now.
- Assistant
Need to fix the second occurrence at createSubagent.
- Assistant
The second occurrence still has the private constructor call that no longer exists (private)! Need tomake fix.
- Assistant
Rebuilding and re-running verification.
- Assistant
Cleanup and final check before submitting.
- Assistant
sed syntax wrong, use sed -n '129,180p'
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.