Skip to content
TheChatArchiveThe Chat Archive
DeepSeekdeepseek/deepseek-v4-pro· deepseekHugging 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. DeepSeek Assistant

    Let me start by understanding the repository structure and the issue. The bug is about duplicate activate_skill tool definition error when using AgenticServices.createAgenticSystem(). Let me explore the relevant files.

    Let me first look at the repository structure and find the relevant files.

  3. DeepSeek Assistant

    Let me look at the key files mentioned in the issue:

    1. AgenticServices.java - the main file with the bug
    2. ToolService.java - where the error is thrown
    3. The Skills/ToolProvider related files

    Let me start by examining the AgenticServices.java file.

  4. DeepSeek Assistant

    Let me open and read the file.

  5. DeepSeek Assistant

    Let me see the full file, particularly the createAgenticSystem method and surrounding code.

  6. DeepSeek Assistant

    Let me read the createAgenticSystem method.

  7. DeepSeek Assistant

    Let me read the createAgenticSystem methods and the ToolService where the error occurs

  8. DeepSeek Assistant

    Now let me look at the configureAgent method in DeclarativeUtil.java and the ToolService.java where the error occurs

  9. DeepSeek Assistant

    Let me read the DeclarativeUtil.java file.

  10. DeepSeek Assistant

    Let me look at the AgentBuilder and understand how tool providers are handled, and also look at the Skills class.

  11. DeepSeek Assistant

    Now let me look at the ToolService.java where the error occurs, and also the AgentBuilder to see how tool providers are handled

  12. DeepSeek Assistant

    Let me read around line 398 of ToolService.java where the error is thrown

  13. DeepSeek Assistant

    Let me read more of ToolService.java to understand the full flow:

  14. DeepSeek Assistant

    Let me look at the AgentBuilder to see how tool providers are accumulated.

  15. DeepSeek Assistant

    Let me read the AgentBuilder.java file.

  16. DeepSeek Assistant

    Let me look at the setupTools method in the AgentBuilder:

  17. DeepSeek Assistant

    Let me look at the setupTools

  18. DeepSeek Assistant

    Let me check all places where AgentBuilder is constructed:

  19. DeepSeek Assistant

    Let me check all callers of configureAgent:

  20. DeepSeek Assistant

    Let me check line 598 of AgenticServices

  21. DeepSeek Assistant

    Let me check what uses AgentBuilder (including tests):

  22. DeepSeek Assistant

    Let me search for patterns where agentBuilder is used with .build() directly

  23. DeepSeek Assistant

    Let me look at AgentUtil.java line

  24. DeepSeek Assistant

    Let me look at the UntypedAgentBuilder to understand the pattern better

  25. DeepSeek Assistant

    Let me look at the validateChatModel method in AgentBuilder:

  26. DeepSeek Assistant

    Let me read the validateChatModel method

  27. DeepSeek Assistant

    Now let me look at the two key places where the duplication happens. Let me also check if there are tests that validate this behavior

  28. DeepSeek Assistant

    Let me check if there are any tests that directly construct AgentBuilder or use agentBuilder().build():

  29. DeepSeek Assistant

    Now I have a clear understanding of the problem. Let me reproduce it first and then fix it.

    The Problem:

    • AgentBuilder constructor calls configureAgent(agentServiceClass, this) (line 141)
    • createAgenticSystem and createSubagent call configureAgent AGAIN after constructing via agentBuilder()
    • This results in duplicate tool provider registrations, causing the activate_skill duplicate error

    The Fix Plan:

    1. Remove configureAgent call from AgentBuilder constructor
    2. Add it to the agentBuilder(Class) factory method (so direct builder usage still works)
    3. In createAgenticSystem and createSubagent, create AgentBuilder directly (not via factory) and call configureAgent only once with the proper parameters

    Let me first look at the Skills class to understand the tool provider structure

  30. DeepSeek Assistant

    Now I have a clear understanding of the bug. Let me implement the fix.

    The root cause: AgentBuilder constructor calls configureAgent(), then createAgenticSystem and createSubagent call configureAgent() again, resulting in duplicate tool provider registration.

    My fix:

    1. Remove configureAgent call from AgentBuilder constructor
    2. Add configureAgent call to the agentBuilder(Class) factory method
    3. In createAgenticSystem, construct AgentBuilder directly (not via factory) to avoid double configureAgent
    4. In createSubagent, construct AgentBuilder directly (not via factory)

    Let me start:

  31. DeepSeek Assistant

    First, remove configureAgent from Agent

  32. DeepSeek Assistant

    Now let me also clean up the extra blank line. Then update the factory method:

  33. DeepSeek Assistant

    I accidentally broke the code. Let me fix the edit properly.

  34. DeepSeek Assistant

    I lost the this.name = line. Let me restore

  35. DeepSeek Assistant

    Let me restore the file and try a different approach.

  36. DeepSeek Assistant

    Now let me use the replace command with heredoc to safely handle the !

  37. DeepSeek Assistant

    Good, the constructor is clean. Now I need to:

    1. Remove the unused configureAgent import from AgentBuilder.java
    2. Add configureAgent to the agentBuilder(Class) factory method
    3. Fix createAgenticSystem and createSubagent

    Let me first remove the unused import:

  38. DeepSeek Assistant

    Let me scroll to the top of the

  39. DeepSeek Assistant

    Now remove the unused import

  40. DeepSeek Assistant

    Good. Now let me update the factory method agentBuilder(Class) in AgenticServices.java to add configureAgent call:

  41. DeepSeek Assistant

    Now update the factory method to call configureAgent:

  42. DeepSeek Assistant

    Now let me update createAgenticSystem to NOT go through the factory method. Let me find the relevant code:

  43. DeepSeek Assistant

    Now let me fix createAgenticSystem. Replace the agentBuilder factory call with direct construction:

  44. DeepSeek Assistant

    Let me try again with explicit file path:

  45. DeepSeek Assistant

    Let me view the exact text at that location:

  46. DeepSeek Assistant

    Let me try the replace with the exact indentation:

  47. DeepSeek Assistant

    Let me go to the line first

  48. DeepSeek Assistant

    Now use edit to replace the specific lines:

  49. DeepSeek Assistant

    Now let me fix createSubagent. Let me find and view it:

  50. DeepSeek Assistant

    Let me view the createSubagent method:

  51. DeepSeek Assistant

    Now fix the createSubagent method:

  52. DeepSeek Assistant

    Now fix the createSubagent method:

  53. DeepSeek Assistant

    Let me verify the imports are in order. Let me check that AgentBuilder is imported:

  54. DeepSeek Assistant

    Good. Now let me also check if there are any other places that might need similar fixing. Let me look at the AgentUtil.agentToExecutor method:

  55. DeepSeek Assistant

    Let me verify the AgentBuilder constructor looks clean now:

  56. DeepSeek Assistant

    Good. Now let me compile and run the relevant tests. Let me first try to compile the changed files:

  57. DeepSeek Assistant

    Compilation succeeded. Now let me run the tests:

  58. DeepSeek Assistant

    Let me get the summary of the test results:

  59. DeepSeek Assistant

    All 45 tests in langchain4j-agentic pass, plus 322 from dependencies. BUILD SUCCESS. Let me also check if there are tests in other modules that test the Skills/agentic interaction:

  60. DeepSeek Assistant

    Let me rerun with more output:

  61. DeepSeek Assistant

    Let me also run the agentic-patterns tests since they use `createAgentic

  62. DeepSeek Assistant

    All tests pass. Let me also run the Skills tests:

  63. DeepSeek Assistant

    All tests pass! Let me do a final review of all my changes:

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