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 trace
createAgenticSystemand the agent/tool-provider registration flow, identify where non-dynamic providers are duplicated, then make the smallest general fix. I’ll run focused tests (and, if needed, a temporary reproduction) without modifying repository tests, inspect the resulting diff, and submit only after verification. - Assistant
The duplication is caused by
AgentBuilderalready applying declarative suppliers in its constructor, whileAgenticServicesapplies them a second time after construction. This affects both the top-level plain agent and declaratively created subagents. I’ll preserve the constructor’s one-time declarative setup, add a narrowly scoped second-phase configuration that only supplies the inherited chat model when needed and runs the user configurator, and use that phase fromAgenticServices. - Assistant
The first edit attempt could not run because this environment lacks
python3; no files were changed. I’ll apply the same small refactor with available shell tools, then compile and run focused tests. - Assistant
The fix is now in place; the repository wrapper requires
HOMEto be explicitly set in this shell, and the oldconfigureAgentstatic import became unused after switching both call sites. I’ll remove that import and rerun compilation withHOMEset, then run the module’s relevant unit tests. - Assistant
Verification is complete. The focused
langchain4j-agentictest suite passes, and compilation succeeds. Spotless/checkstyle commands are not usable as repository-wide quality gates here (Spotless cannot resolve the absentorigin/main; standalone checkstyle reports thousands of pre-existing violations), while the changed code passesgit diff --check. The fix also covers nested declarative subagents, not just the single-agent reproduction.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.