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 the relevant AgenticServices code to understand how createAgenticSystem registers tools.

  3. Assistant

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

  4. Assistant

    rg is not available, let me use grep instead.

  5. Assistant

    Let me open the file around createAgenticSystem methods.

  6. Assistant

    Let me search for ToolProviderSupplier and how tools are configured.

  7. Assistant

    Looking at AgentBuilder constructor - it calls configureAgent, and createAgenticSystem may call it again.

  8. Assistant

    I've confirmed double configureAgent registration. Checking recent changes and related skill/activate_skill code next.

  9. Assistant

    I'll inspect ToolService and AgentBuilder tool setup — dual configureAgent and list accumulation look like the source of the duplicate.

  10. Assistant

    Looking at git history and tests around the double configuration path.

  11. Assistant

    Looking at TestService to understand how non-dynamic tool providers cause the issue with activate_skill.

  12. Assistant

    Let me look at ToolService around createContextFromStaticToolsAndProviders

  13. Assistant

    Interesting - ToolService uses a Set for toolProviders:The bug is clear: createAgenticSystem (and AgentBuilder) registers ToolProvider instances from @ToolProviderSupplier methods multiple times because each call to configureAgent creates a fresh Skills.toolProvider() instance. The activate_skill tool is baked into every non-dynamic provider, causing the duplicate registration in ToolService.

    I should fix this by ensuring configureAgent is called only once per agent class, so each @ToolProviderSupplier method is processed only once. This is the root cause fix.

    Let me check the current code structure to see how to implement this cleanly.

  14. Assistant

    Checking whether listener and other builders accumulate values across the dual configureAgent calls.

  15. Assistant
    public B listener(AgentListener agentListener) {
    
  16. Assistant

    Looking at Skills.toolProvider isDynamic:

  17. Assistant

    Checking all callers of configureAgent to pick a safe fix.

  18. Assistant

    Checking how chat model state is tracked on AgentBuilder so we can skip reapplying suppliers safely.

  19. Assistant

    Root cause: configureAgent runs twice and re-adds tools/listeners. I'll skip reapplying declarative suppliers on the second call and only fill in chat model + configurator.

  20. Assistant

    I'll add a flag so declarative suppliers run only once, then only the chat-model fallback and configurator run on the second pass.

  21. Assistant

    Next I'll clean up the constructor spacing and update DeclarativeUtil.

  22. Assistant

    I accidentally broke hasChatModelConfigured — restoring the missing check and brace.

  23. Assistant

    Need blank line before constructor again.

  24. Assistant

    Updating DeclarativeUtil.configureAgent to skip already-applied suppliers.

  25. Assistant

    Verifying the rest of DeclarativeUtil for leftover or duplicated code.

  26. Assistant

    Fixing the comment typo, then writing a reproduction test.

  27. Assistant

    Checking dependencies and whether we can reproduce with a unit test.

  28. Assistant

    I'll reproduce with a custom static ToolProvider (no skills dependency) and check existing mock chat model patterns.

  29. Assistant

    Compiling the agentic module and drafting a short reproduction.

  30. Assistant

    HOME not set - need to set it.

  31. Assistant

    Creating a temporary reproduction test to run and then remove.

  32. Assistant

    Agent is not in declarative package — locating where it's defined.

  33. Assistant

    Also need ToolProviderResult.builder API.

  34. Assistant

    Let me fix the repro and run again.

  35. Assistant

    Confirming the pre-fix failure still reproduces when suppliers are reapplied.

  36. Assistant

    Using perl for a temporary patch to confirm the original bug.

  37. Assistant

    Restoring the fix after the temporary checkout wiped it.

  38. Assistant

    Reapplying DeclarativeUtil changes next.

  39. Assistant

    I'll use the edit command to replace the private configureAgent method.

  40. Assistant

    Compiling and re-running the reproduction, then unit tests that do not need API keys.

  41. Assistant

    Main fix is good. Checking SequenceAgent usage and compiling the agentBuilder path separately.

  42. Assistant

    subAgents takes Class[] not @SubAgent. Fixing the parent-model reproduction.

  43. Assistant

    Running unit tests that don't need external services.&embedding.

  44. Assistant

    The test command didn't show output - maybe wallpaper silent success? Let me check exit code and run with more output.

  45. Assistant

    Moving the flag into DeclarativeUtil so we don't pollute the public AgentBuilder API.

  46. Assistant

    Restoring the AgentBuilder helpers — they match existing patterns like hasChatMemory().

  47. Assistant

    Recompiling and verifying everything still works.

  48. Assistant

    Cleaning up temp files and verifying the final diff before submit.

  49. Assistant

    Checking visibility of similar AgentBuilder helpers so we match the existing style.

  50. Assistant

    Refactoring to keep tracking in DeclarativeUtil so we don't add public surface on AgentBuilder.

  51. Assistant

    Fixing the typo and switching to the WeakHashMap-based tracking.

  52. Assistant

    Cleaning up the leftover duplicate lines and updating applyParentChatModelIfMissing.

  53. Assistant

    Need to fix applyParentChatModelIfMissing to not use hasChatModelConfigured.

  54. Assistant

    Replacing hasChatModelConfigured with a check for chat-model supplier annotations on the class.

  55. Assistant

    Compiling and re-running verification.

  56. Assistant

    Simplifying the compile-and-repro flow after the nested heredocs confused the shell.

  57. Assistant

    Compile ˌsucceeded. Writing the repro file cleanly.

  58. Assistant

    Writing the repro file via base64 to avoid input corruption.

  59. Assistant

    Let me use perl with a simpler approach - write line by line.

  60. Assistant

    Writing the repro file in smaller chunks with printf.

  61. Assistant

    There's leftover garbage in the imports — rewriting the file carefully.

  62. Assistant

    Using the editor create command to write the temp repro file cleanly.

  63. Assistant

    Let me create under repo path.

  64. Assistant

    Good, now use edit to fill it.

  65. Assistant

    Fixing the corrupted lines with precise replacements.

  66. Assistant

    Still some corruption. Let me fix remaining bad lines.

  67. Assistant

    Just need to fix line 88 returnnew -> returnms new

  68. Assistant

    Rename file and run.

  69. Assistant

    All three scenarios pass. Verifying the final source and preparing to submit.

  70. Assistant

    Syntax error due to my typo. Let me run cleanly.

  71. Assistant

    The mvn test output was empty in the head - let me check if tests۰۰ ran.

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