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 the duplicate tool registration issue.

  3. Assistant

    Next I'll inspect AgenticServices.java and the skills/tool-provider related code.

  4. Assistant

    rg is not found, let me use grep instead.

  5. Assistant

    I'll inspect the createAgenticSystem implementation and how tool providers get registered.

  6. Assistant

    Let me look at AgentBuilder and DeclarativeUtil for how tools are configured. Also look at skills package.

  7. Assistant

    I'll examine AgentBuilder's tool provider handling and how Skills contributes activate_skill.

  8. Assistant

    I'll look at ToolService for how static vs dynamic tool providers are handled and where duplicates are introduced.

  9. Assistant

    Let me read the ToolService createContextFromStaticToolsAndProviders method fully.

  10. Assistant

    Checking recent commits and AgentBuilder for double-registration of tool providers.

  11. Assistant

    Checking whether agentBuilder already applies configuration, which could cause double registration.

  12. Assistant

    I've confirmed the double configureAgent path. Checking history and tests for the intended design.

  13. Assistant

    I'll check how listeners and chat model overrides behave under this double-configuration path.

  14. Assistant

    Let me see the listener method fully and how ComposedAgentListener works.

  15. Assistant

    For listeners if configureAgent runs twice with AgentListenerSupplier: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.

    I have reviewed the issue description and the provided code snippet. The root cause is that AgenticServices.createAgenticSystem() calls configureAgent twice—once in the AgentBuilder constructor and once in the explicit call—resulting in duplicate ToolProvider registrations and the activate_skill tool being added twice.

    To fix this, I will restructure the AgentBuilder creation logic so that configureAgent is invoked only once for the full configuration (including tools, chat model, and configurator). This will prevent duplicate registrations while preserving the existing agentBuilder(Class).build() behavior.

    I will implement this by introducing a flag in AgentBuilder to skip the auto-configuration in the constructor, and use a new factory method unconfigured for createAgenticSystem.

    Let me proceed with the changes. First, I'll check the current state of the file.

    I need to modify AgenticServices.java to use the skip-auto-configure path.

    Let me also check for the same pattern in createBuiltInAgentExecutor.

    I will make the changes to prevent double configuration.

    Let me implement the fix.

    I will add a new constructor and factory method to AgentBuilder to support unconfigured creation.

    Let me proceed with the code changes.

  16. Assistant

    I'll implement a bare AgentBuilder path so configuration only happens once.

  17. Assistant

    Let me fix the grep.

  18. Assistant

    Let me see line 590-605 of AgenticServices more carefully.

  19. Assistant

    Confirming the double-configureAgent path. I'll check for an existing dummy model we can use to reproduce.

  20. Assistant

    I'll check module dependencies and then implement and verify the fix.

  21. Assistant

    Implementing the fix: construct the builder without declarative configuration when createAgenticSystem will configure it explicitly.

  22. Assistant

    I'll check if Internal import already exists in AgentBuilder.

  23. Assistant

    Need to open the file first or use exact content.

  24. Assistant

    Let me apply the edit to AgentBuilder constructor.

  25. Assistant

    Now replace the constructor.

  26. Assistant

    I need to navigate to the constructor first.

  27. Assistant

    Now try the replace again.

  28. Assistant

    Now update AgenticServices to use the new constructor with false.

  29. Assistant

    I need to check imports for AgentBuilder - already imported.

  30. Assistant

    Now fix createSubagent as well.

  31. Assistant

    Fix createSubagent.

  32. Assistant

    I'll write a temporary reproduction script and compile to verify the fix.

  33. Assistant

    Building the required modules, then adding a reproducer.

  34. Assistant

    HOME is not set. Let me set it.

  35. Assistant

    @Internal is not applicable to constructors. Let me check the Internal annotation.

  36. Assistant

    @Internal only applies to TYPE, METHOD, PACKAGE —I'll switch to an @Internal static factory method instead.

  37. Assistant

    Now update AgenticServices to use the factory method.

  38. Assistant

    Also fix createSubagent.

  39. Assistant

    Need to goto line first

  40. Assistant

    Rebuilding, then writing a temporary reproducer to verify the fix.

  41. Assistant

    Build succeeded. Next I'll create a temporary reproducer to confirm the fix.

  42. Assistant

    Fix confirmed. Running unit tests that don't need API keys:

  43. Assistant

    I'll also verify the subagent path and clean up the temporary reproducer.

  44. Assistant

    Verifying the final diff looks correct.

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