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 codebase.

    Let me start by:

    1. Understanding the repository structure
    2. Finding the relevant files
    3. Reproducing the issue
    4. Fixing it
  3. DeepSeek Assistant

    Let me look at the relevant files. First, the main file mentioned in the issue: langchain4j-agentic/src/main/java/dev/langchain4j/agentic/AgenticServices.java.

  4. DeepSeek Assistant

    Let's look at the AgenticServices.java file:

  5. DeepSeek Assistant

    Let me try to read the file using cat:

  6. DeepSeek Assistant

    Let me search for the createAgenticSystem method and the surrounding context

  7. DeepSeek Assistant

    Let me look at the createAgenticSystem methods starting around line 298

  8. DeepSeek Assistant

    Now let me look at the configureAgent method and AgentBuilder:

  9. DeepSeek Assistant

    Let's look at DeclarativeUtil.java to find configureAgent:

  10. DeepSeek Assistant

    Now let's look at the `AgentBuilder.java

  11. DeepSeek Assistant

    Now let me look at the ToolService class where the error originates

  12. DeepSeek Assistant

    Let me look at this file:

  13. DeepSeek Assistant

    Let me see the relevant sections around the addTools method and createContextFromStaticToolsAndProviders

  14. DeepSeek Assistant

    Let me look at the relevant methods around lines 346-400

  15. DeepSeek Assistant

    Let me look at the AiServices class to understand how toolProviders are handled

  16. DeepSeek Assistant

    Let me look at how toolProviders is set up in AiServices

  17. DeepSeek Assistant

    Let me look at the Skills class to understand how activate_skill tool is registered

  18. DeepSeek Assistant

    Let's look at this file

  19. DeepSeek Assistant

    Let me look at the AgentBuilder constructor flow more carefully:

  20. DeepSeek Assistant

    Let me look at the AgentBuilder constructor to see where configureAgent is called:

  21. DeepSeek Assistant

    Let me trace through the problem more carefully. Let me check if there are other places that call new AgentBuilder:

  22. DeepSeek Assistant

    Let me look at validateChatModel and the rest of `Agent

  23. DeepSeek Assistant

    So configureChatModel calls validateChatModel() and then uses whichever model is set. If no model is set, it throws an exception.

    Now let me look at validateChatModel:

  24. DeepSeek Assistant

    Let me see it:

  25. DeepSeek Assistant

    Now I understand the issue. Let me look at how configureAgent is called:

    In createAgenticSystem:

    1. agentBuilder(agentServiceClass) → new AgentBuilder<>(agentServiceClass) → constructor calls configureAgent(agentServiceClass, this) (first call)
    2. configureAgent(agentServiceClass, chatModel, agentBuilder, agentConfigurator) (second call)

    Both calls invoke @ToolProviderSupplier method and add the ToolProvider to the builder's list. Since the @ToolProviderSupplier returns a new Skills instance each time, two different ToolProvider objects end up in the list, both providing activate_skill → duplicate error.

    Let me also verify the tool providers handling in `ToolService

  26. DeepSeek Assistant

    Let me see the rest of `setupTools

  27. DeepSeek Assistant

    Now I have a clear understanding of the issue. Let me implement the fix. The problem is that configureAgent is called twice:

    1. In AgentBuilder constructor (via agentBuilder(agentServiceClass))
    2. Explicitly in createAgenticSystem (via configureAgent(agentServiceClass, chatModel, agentBuilder, agentConfigurator))

    Both calls invoke the @ToolProviderSupplier method and add the ToolProvider to the list, causing duplicates.

    The fix: Remove configureAgent from AgentBuilder constructor, call it explicitly where needed (in agentBuilder() and once in createAgenticSystem).

    Let me first understand the exact lines:

  28. DeepSeek Assistant

    Let me look at the AgentConfigurator class:

  29. DeepSeek Assistant

    Let me look at the AgentConfigurator record and `DeclarativeAgentCreation

  30. DeepSeek Assistant

    Now I have a clear plan. Let me implement the fix:

    1. Remove configureAgent from AgentBuilder constructor
    2. Add configureAgent call in agentBuilder(Class<T>) method in AgenticServices
    3. In createAgenticSystem, use new AgentBuilder<>(agentServiceClass) directly instead of agentBuilder(), then call configureAgent once

    Let me start:

  31. DeepSeek Assistant

    Let me first remove the configureAgent call from the AgentBuilder

  32. DeepSeek Assistant

    I need to open the file first:

  33. DeepSeek Assistant

    Now let me remove the configureAgent call from the

  34. DeepSeek Assistant

    Now remove the configureAgent call from the constructor

  35. DeepSeek Assistant

    Now let me also remove the unused import of configureAgent from Agent

  36. DeepSeek Assistant

    Now let me update AgenticServices.java. Let me open it:

  37. DeepSeek Assistant

    Let me find the agentBuilder() method:

  38. DeepSeek Assistant

    Let me see lines 115-125

  39. DeepSeek Assistant

    Now let me update agentBuilder() to call configureAgent after construction

  40. DeepSeek Assistant

    Now let me update createAgenticSystem. Let me find the method that takes ChatModel and AgentConfigurator

  41. DeepSeek Assistant

    Now let me update the createAgenticSystem method to not call agentBuilder() followed by another configureAgent. Instead, create the builder directly and call `configureAgent

  42. DeepSeek Assistant

    Now let me check if UntypedAgentBuilder also needs similar

  43. DeepSeek Assistant

    Let me check if there are other places in the codebase that might be affected by this change:

  44. DeepSeek Assistant

    Let me try to compile the changes to verify

  45. DeepSeek Assistant

    The code compiles. Let me find and run the relevant tests:

  46. DeepSeek Assistant

    Let me look for tests that use createAgenticSystem or agentBuilder

  47. DeepSeek Assistant

    Let me also compile the test sources to make sure everything is correct:

  48. DeepSeek Assistant

    Good, compilation succeeded. Let me also check if there are any other callers of configureAgent that might be affected

  49. DeepSeek Assistant

    Let me check line 600 where configureAgent is

  50. DeepSeek Assistant

    This is another place with the same issue! Let me see the full context

  51. DeepSeek Assistant

    I need to fix this too. Let me update

  52. DeepSeek Assistant

    Let me recompile to verify

  53. DeepSeek Assistant

    Let me compile tests too

  54. DeepSeek Assistant

    All compiles fine. Let me review the final diff of my

  55. DeepSeek Assistant

    Let me verify there are no other places where the same configureAgent pattern could cause issues

  56. DeepSeek Assistant

    Let me check line 100 in `

  57. DeepSeek Assistant

    Let me check the DeclarativeAgentCreationContext interface to understand its usage:

  58. DeepSeek Assistant

    Let me verify the UntypedAgentBuilder usage is fine by checking the UntypedAgent class:

  59. DeepSeek Assistant

    Let me also search for any remaining patterns where agentBuilder() is followed by another `

  60. DeepSeek Assistant

    The fix looks complete. Let me now submit the changes. But first, let me verify the change one more time by running a quick unit test

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