Skip to content
TheChatArchiveThe Chat Archive
x-ai/grok-4.5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION [BUG] Duplicate activate_skill tool definition error when using…

  1. User

    ISSUE DESCRIPTION

    [BUG] Duplicate activate_skill tool definition error when using AgenticServices.createAgenticSystem() Describe the bug When creating an agentic system with AgenticServices.createAgenticSystem(), even with a single agent, the application throws an IllegalConfigurationException: Duplicated definition for tool: activate_skill during execution, caused by multiple registrations of non-dynamic ToolProvider instances.

    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 more
    

    To 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_skill tool) when registering non-dynamic ToolProvider instances.

    Please complete the following information:

    • LangChain4j version: latest agentic snapshot
    • LLM(s) used: Qwen 3.6 (via OpenAiChatModel)
    • Java version: 25
    • Spring Boot version (if applicable): N/A

    Additional context The bug is caused by createAgenticSystem registering non-dynamic ToolProvider instances multiple times. The activate_skill tool is automatically added for every SkillProvider instance, leading to duplicate registration even with a single agent.

    Interface

    Type: Function Name: createAgenticSystem Path: langchain4j-agentic/src/main/java/dev/langchain4j/agentic/AgenticServices.java Input: Class agentServiceClass, AgentConfigurator agentConfigurator Output: T (the created agentic system instance of the requested type) Description: Creates an agentic system from a declarative agent service class, applying the provided configurator to each agent. This overload resolves the default chat model from the agent class and deduplicates tool registrations across the system.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /langchain4j, current file: none) bash-$

  2. Assistant

    I'll start by exploring the repository structure and locating the relevant code for createAgenticSystem and tool registration.

  3. Assistant

    Next I'll inspect createAgenticSystem and how tools/skills get registered.

  4. Assistant

    rg is not found, I'll use grep instead.

  5. Assistant

    Let me open the createAgenticSystem methods and related code.

  6. Assistant

    Let me look at configureAgent and how ToolProviders are registered.

  7. Assistant

    So configureAgent is in DeclarativeUtil. Let me find that.

  8. Assistant

    I'll inspect AgentBuilder around tool registration and the Skills module next.

  9. Assistant

    I'll examine ToolService's handling of dynamic vs non-dynamic providers and how Skills builds its ToolProvider.

  10. Assistant

    Checking whether Skills' toolProvider is marked dynamic and how ToolService merges providers.

  11. Assistant

    Examining isDynamic and ToolService context-creation for double registration.

  12. Assistant

    I'll dig into DeclarativeUtil and AgentBuilder.build, and check recent history for tool-provider changes.

  13. Assistant

    I'll inspect AgentBuilder.build and how toolProviders flow into AiServices.

  14. Assistant

    I think configureAgent may run twice — verifying the constructor and createAgenticSystem paths.

  15. Assistant

    Confirming double configuration — reading the rest of configureAgent to see the full impact.

  16. Assistant

    I'll scan the rest of configureAgent for additive vs replacing setters.

  17. Assistant

    Checking tests and other call sites of configureAgent/agentBuilder for the right fix approach.

  18. Assistant

    Checking all construction sites of AgentBuilder:

  19. Assistant

    I'll check AgentBuilder field visibility so we can apply only the chat model and configurator on the second path.

  20. Assistant

    Checking how listener handles multiple registrations:

  21. Assistant

    Implementing the fix: prevent double configuration by only applying chat model fallback and configurator on the second pass.

  22. Assistant

    Implementing the fix: AgentBuilder already runs declarative config, so the second path will only apply chat-model fallback and the configurator.

  23. Assistant

    I'll jump to the right lines and apply the edit.

  24. Assistant

    Let me use the edit command with line ranges.

  25. Assistant

    Updating DeclarativeUtil so the ChatModel overload only fills in the model fallback and runs the configurator.

  26. Assistant

    I'll change the 4-arg configureAgent method to not re-run full configuration. I'll leave the private method for constructor path.

  27. Assistant

    There's still something wrong: the 2-arg configureAgent still calls the private 5-arg method. Let me verify that private method still ends correctly and applies the empty configurator.

  28. Assistant

    Next I’ll repro the bug with a small unit test and compile the relevant modules.

  29. Assistant

    I'll write a temporary repro that uses a mock non-dynamic ToolProvider and a stub ChatModel.

  30. Assistant

    I'll check SingleAgentIT, ChatSupplierParameterResolverTest, and StubChatModel for patterns I can reuse.

  31. Assistant

    I'll compile the agentic module and craft a temporary repro script.

  32. Assistant

    HOME is unset — I'll set it and retry the build.

  33. Assistant

    Compilation succeeded. Next I’ll add a temporary test program to verify the fix.

  34. Assistant

    Classpath may omit the module itself — I'll include target/classes and run the repro.

  35. Assistant

    Fix looks good. Next I'll verify chat-model fallback and configurator, and double-check the old path would have duplicated providers.

  36. Assistant

    I'll run the non-integration unit tests that should still pass.

  37. Assistant

    Cleaning up leftover private-method parameters and reviewing the final diff.

  38. Assistant

    I'll rename the private method and simplify it.

  39. Assistant

    I still need to clean up the chat-model else branch and drop the obsolete parameters.

  40. Assistant

    Recompiling and re-running the unit tests to confirm everything still works.

  41. Assistant

    I'll check the Maven surefire results next.

  42. Assistant

    The fix is verified. Cleaning up temp files and submitting.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.