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
createAgenticSystemcode to understand the duplicate tool registration bug. - Assistant
I'll inspect
createAgenticSystemand how tool providers are registered. - Assistant
rg is not available, let me use grep instead.
- Assistant
Let me read the full createAgenticSystem method and related code.
- Assistant
I'll look at configureAgent and tool provider handling next.
- Assistant
I suspect
configureAgentruns twice on the createAgenticSystem path — verifying that. - Assistant
Confirming:
AgentBuilderconfigures once in its constructor, andcreateAgenticSystemconfigures again. Checking of subagent creation paths and related tests. - Assistant
Checking how repeated configuration affects tools versus other settings.
- Assistant
I'll check every AgentBuilder construction path and the recent git history for related changes.
- Assistant
Looking at ToolService and how Skills registers activate_skill.
- Assistant
Checking whether listener and other additive fields also get duplicated.
- Assistant
Let me look at listener:
- Assistant
I'll inspect how AgentBuilder is constructed across the codebase.
- Assistant
I'll check the AgentBuilder documentation and MonitoredAgent usage.
- Assistant
Root cause:
configureAgentruns twice andtoolProvideris additive. Fixing by configuring declaratively only once. - Assistant
Implementing a flag so declarative configuration (including tool providers) runs only once while chat model and configurator still apply.
- Assistant
Reconsidering: avoiding a public API flag and instead only applying chat model + configurator on the second pass.
- Assistant
I'll check how
@Internalis used and implement a clean solution. - Assistant
Implementing an internal constructor to skip automatic declarative config, and using it from
createAgenticSystem. - Assistant
I'll open the file at the imports and apply the edit.
- Assistant
Let me implement the constructor change and AgenticServices change.
- Assistant
Now update the constructor.
- Assistant
I need to navigate to that line first.
- Assistant
OK now I can replace.
- Assistant
Updating
AgenticServicesto use the unconfigured builder path. - Assistant
Now I need to check if AgentBuilder is already imported or needs to be.
- Assistant
I'll update both places that double-configure.
- Assistant
Now fix createSubagent as well.
- Assistant
Update createSubagent similarly.
- Assistant
I'll write a small reproduction script to verify the duplicate-tool error and the fix.
- Assistant
Skills claims to be dynamic — checking whether that matches the duplicate-tool path.
- Assistant
Let me see isDynamic on the Skills toolprovider
- Assistant
Compiling the module and running a reproduction that registers a non-dynamic ToolProvider twice via createAgenticSystem.
- Assistant
Building the required modules so we can run a reproduction.
- Assistant
HOME is not set. Let me set it.
- Assistant
@Internalcan't annotate constructors — removing it. - Assistant
Need to go to that line first.
- Assistant
Let me remove Internal import and @Internal annotation.
- Assistant
Now remove the @Internal annotation from the constructor.
- Assistant
Remove @Internal annotation.
- Assistant
Recompiling now.
- Assistant
Build succeeded. Creating a temporary reproduction to verify the fix.
- Assistant
Checking ToolExecutor signature and correcting the classpath to use SNAPSHOT builds.
- Assistant
Fixing the ToolExecutor usage and classpath.
- Assistant
Confirming the old double-configure path still fails, then running related tests.
- Assistant
Old path unexpectedly succeeded — investigating further.
- Assistant
Writing the debug repro carefully with a heredoc.
- Assistant
Exactly reproduced the original error. Running existing agentic unit tests next.
- Assistant
Checking which tests can run offline.
- Assistant
Running local unit tests that use dummy models.
- Assistant
Tests passed. Reviewing the final diff and cleaning up.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.