Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging 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. Claude Assistant

    Now let's implement the fix. I'll refactor DeclarativeUtil.configureAgent to split static (accumulating) suppliers from the chat-model/configurator logic, so the second overload (used only right after a fresh AgentBuilder construction) doesn't re-apply the accumulating suppliers a second time.

  3. Claude Assistant

    Let's use the edit special command instead.

  4. Claude Assistant

    Now let's replace lines 46-149 with the refactored version.

  5. Claude Assistant

    Looks good. Let's scroll down to verify rest of the file is intact.

  6. Claude Assistant

    The rest of the file remains unchanged. Now let's build the module to check for compile errors.

  7. Claude Assistant

    Good, it compiled (no output means success, given -q). Let's verify explicitly.

  8. Claude Assistant

    Compilation succeeds. Now let's write a reproduction test to verify the fix resolves duplicate tool registration, using the langchain4j-skills module referenced in the issue.

  9. Claude Assistant

    Now let's write a temp reproduction test.

  10. Claude Assistant

    Good, the ToolExecutor signature matches. Let's fix the import for @Agent (already imported via full package reference used inline; but let's use proper import instead for clarity) and remove unused import for DefaultToolExecutor.

  11. Claude Assistant

    Now let's first revert our fix temporarily to confirm the test reproduces the bug, then reapply.

  12. Claude Assistant

    It passed with our fix. Now let's confirm it fails without the fix (revert temporarily).

  13. Claude Assistant

    Good, the test file remains untracked (not stashed). Let's run the test now with the original buggy code to confirm reproduction.

  14. Claude Assistant

    Now run test on the unpatched (reverted) code to confirm the bug reproduces.

  15. Claude Assistant

    Reproduced exactly the reported error. Now let's restore our fix (pop the stash) and re-run to confirm resolution.

  16. Claude Assistant

    Fix confirmed. Now let's remove the temporary reproduction test file and run the full existing test suite for the agentic module to make sure nothing broke.

  17. Claude Assistant

    Good, ITs are excluded from test phase (only run via failsafe verify/integration-test). So mvn test should only run unit tests (non-IT).

  18. Claude Assistant

    Only the two call sites we already accounted for use the 4-arg overload, and both are always preceded by fresh AgentBuilder construction (which always applies the static config exactly once via the constructor). Good — our fix covers all current usages.

  19. Claude Assistant

    Confirmed. Both call sites do agentBuilder(...) immediately before calling the 4-arg configureAgent. Let's view the final diff.

  20. Claude Assistant

    This is clean. Let's run the full test suite once more (already did) and also check other modules that might reference DeclarativeUtil.configureAgent (e.g., mcp, a2a agentic extension modules).

  21. Claude Assistant

    No other module references DeclarativeUtil directly. Let's also run the related sibling modules that depend on langchain4j-agentic (e.g. langchain4j-agentic-mcp, langchain4j-agentic-a2a, langchain4j-agentic-patterns) to be safe.

  22. Claude Assistant

    All builds and tests pass. Let's also double check git status to ensure only the intended file is modified and no leftover temp files.

  23. Claude Assistant

    Clean. Let's review the checklist items:

  24. Claude Assistant

    This is the complete, focused fix. Let me now go through the checklist:

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