ISSUE DESCRIPTION [BUG] Duplicate activate_skill tool definition error when using…
- User
ISSUE DESCRIPTION
[BUG] Duplicate
activate_skilltool definition error when usingAgenticServices.createAgenticSystem()Describe the bug When creating an agentic system withAgenticServices.createAgenticSystem(), even with a single agent, the application throws anIllegalConfigurationException: Duplicated definition for tool: activate_skillduring execution, caused by multiple registrations of non-dynamicToolProviderinstances.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 moreTo 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_skilltool) when registering non-dynamicToolProviderinstances.Please complete the following information:
Assistant
Let me start by understanding the issue. The bug is about duplicate
activate_skilltool definition error when usingAgenticServices.createAgenticSystem(). The error occurs becauseactivate_skillis being registered multiple times.Let me first explore the repository structure to understand the codebase.
Assistant
Let me find the AgenticServices file first.
Assistant
Now let me read the AgenticServices file and understand the issue.
Assistant
Let me look at the
createAgenticSystemmethod specifically:Assistant
Let me see the full content of those methods.
Assistant
Let me see more of the file, especially the
createSubagentsmethod and related tool registration code:Assistant
Now let me look at the ToolService class where the error is thrown:
Assistant
Let me look at the AgentBuilder class:
Assistant
Let me read the AgentBuilder.java file:
Assistant
Now let me look at the
DeclarativeUtil.configureAgentmethod to understand how tool providers are being configured:Assistant
Let me read the DeclarativeUtil.java file to understand how tool providers are being configured.
Assistant
Now let me search for where
activate_skilltool is being added:Assistant
Now let me look at the Skills.java file to understand how the
activate_skilltool is provided:Assistant
Now I need to understand the full flow of how tool providers are registered. Let me search for more details about how this works:
Assistant
Let me continue examining the code flow and find all places where
configureAgentis called:Assistant
Assistant
Let me search for all places where AgentBuilder is instantiated or agentBuilder is called.
Assistant
Let me check the AgentUtil usage to see if it calls configureAgent after creating the agentBuilder:
Assistant
Let me explore the repository structure and understand how the duplicate registration happens.
Assistant
Assistant
Let me find all occurrences of
createBuiltInAgentExecutorto understand where it's defined and used.Assistant
Let me understand the issue better by looking at the full code paths:
Assistant
Assistant
Let me find test files for the agentic module.
Assistant
Let me look for tests specifically related to createAgenticSystem.
Assistant
Now I have a clear understanding of the issue. Let me trace through the code to confirm my understanding:
createAgenticSystemcallsagentBuilder(agentServiceClass)which creates a newAgentBuilder- The
AgentBuilderconstructor callsconfigureAgent(agentServiceClass, this)which processes@ToolProviderSupplierand adds the tool provider totoolProviderslist createAgenticSystemthen callsconfigureAgent(agentServiceClass, chatModel, agentBuilder, agentConfigurator)which processes@ToolProviderSupplieragain and adds the tool provider again- When
build()is called, the duplicate tool providers are passed toAiServices - When
createContextFromStaticToolsAndProvidersis called, both non-dynamic tool providers provide the same tools (includingactivate_skill) addToolsthrows an exception becauseactivate_skillis already registered
Let me look at the fix. The simplest and most general fix is to modify
ToolService.addToolsto skip duplicate tools instead of throwing an exception.Assistant
Now I understand the issue completely. The root cause is:
-
In
createAgenticSystem,configureAgentis called twice for the same agent:- Once in the
AgentBuilderconstructor (viaagentBuilder(agentServiceClass)) - Once explicitly in
createAgenticSystem
- Once in the
-
Each call to
configureAgentprocesses the@ToolProviderSupplierannotation and invokes the supplier method, adding a newToolProviderinstance to thetoolProviderslist. -
When
createContextFromStaticToolsAndProvidersprocesses these non-dynamicToolProviderinstances, both provide the same tools (includingactivate_skill), andaddToolsthrows an exception because it detects duplicate tool definitions.
The fix is to skip duplicate tools instead of throwing an exception. Let me implement this:
-
Assistant
Now I understand the issue. The problem is that when
AgenticServices.createAgenticSystem()is called, it callsconfigureAgent()twice for the same agent:- Once in the
AgentBuilderconstructor - Once explicitly in
createAgenticSystem()
Each call processes the
@ToolProviderSupplierannotation and invokes the supplier method, adding a newToolProviderinstance to the list. When these non-dynamicToolProviderinstances provide tools (including the built-inactivate_skill), theaddTools()method throws an exception because it detects duplicate tool definitions.The fix is to modify
addTools()to skip duplicate tools instead of throwing an exception. This properly deduplicates tools when registering non-dynamicToolProviderinstances.Let me implement the fix:
- Once in the
Assistant
Now let me implement the fix. I need to modify the
addToolsmethod inToolService.javato skip duplicate tools instead of throwing an exception. The fix is to change the exception throwing to a continue statement that skips the duplicate tool.Assistant
The issue is clear now. The
createAgenticSystemmethod callsconfigureAgenttwice:- Once in the
AgentBuilderconstructor (viaagentBuilder(agentServiceClass)) - Once explicitly in
createAgenticSystem
This causes the
@ToolProviderSuppliermethod to be invoked twice, creating two differentToolProviderinstances. WhencreateContextFromStaticToolsAndProvidersprocesses these non-dynamic providers, both provide the same tools (includingactivate_skill), andaddToolsthrows because of duplicate tool names.The fix should modify
ToolService.addToolsto skip duplicate tools instead of throwing an exception. This allows the agentic system to run successfully while properly deduplicating tools.- Once in the
Assistant
Now I understand the issue. The
createAgenticSystemmethod callsconfigureAgent()twice:- Once in the
AgentBuilderconstructor (viaagentBuilder(agentServiceClass)) - Once explicitly in
createAgenticSystem
This causes the
@ToolProviderSuppliermethod to be invoked twice, creating two differentToolProviderinstances. WhencreateContextFromStaticToolsAndProvidersprocesses these non-dynamic providers, both provide the same tools (includingactivate_skill), andaddToolsthrows because of duplicate tool names.The fix is to modify
addToolsto skip duplicate tools instead of throwing an exception. Let me implement this:- Once in the
Assistant
Now I understand the issue. The
createAgenticSystemmethod callsconfigureAgent()twice - once in theAgentBuilderconstructor and once explicitly increateAgenticSystem. This causes the@ToolProviderSuppliermethod to be invoked twice, creating twoToolProviderinstances that both provide theactivate_skilltool, leading to the duplicate definition error.The fix is to modify the
addToolsmethod inToolService.javato skip duplicate tools instead of throwing an exception. This properly deduplicates tools when registering non-dynamicToolProviderinstances.Assistant
Let me try a different approach to make the edit.
Assistant
Wait, the sed command with \n might not work correctly. Let me verify the change was made correctly.
Assistant
Good, the change looks correct. Now let me verify that the code compiles and check for any tests that might need to pass:
Assistant
Let me verify the fix by running relevant tests and checking if the code compiles correctly.
Assistant
Let me check the existing tests to ensure they pass with the fix, and also look for the IllegalConfigurationException to see if it's still used elsewhere.
Assistant
Good. The IllegalConfigurationException is still used elsewhere, which is correct - we want to keep it for other configuration errors. My fix only changes the behavior for duplicate tool definitions from ToolProvider instances.
Let me also check if there's a similar issue in ToolProviderResult.java:
Assistant
Let me check the ToolServiceTest to see if there are any tests that expect the duplicate tool exception:
Assistant
The user wants me to run the tests to verify my fix works correctly. Let me check what tests exist and run them.
Assistant
Let me check if there are tests related to this fix and run them.
Assistant
Let me search for any tests that expect the duplicate tool exception behavior that I changed:
Assistant
Let me search for any tests that expect the duplicate tool exception behavior.
Assistant
Let me check the tests that might be affected by my change - specifically the ones related to duplicate tool definitions:
Assistant
Let me check the tests that use IllegalConfigurationException to see if any are related to duplicate tool definitions:
Assistant
Let me check the AiServicesWithToolsIT test that might be related to duplicate tools:
Assistant
Let me check the context of that test to understand what scenario it's testing:
Assistant
Let me look at that test more carefully - it's testing a valid scenario where duplicate tools from different sources (static vs dynamic) should throw an exception. My fix breaks this test. I need to revert my change and instead fix the root cause.
The root cause is that
createAgenticSystemcallsconfigureAgent()twice - once in theAgentBuilderconstructor and once explicitly. Let me revert my change and fix it properly at the source.Assistant
I need to revert my change because there's an existing test
should_throw_if_static_and_dynamic_tools_are_duplicatedthat expects duplicate tools from different sources to throw an exception. My change would break this valid test case.Let me revert the change and instead fix the root cause - the duplicate call to
configureAgentincreateAgenticSystem.Assistant
I see. There's a test
should_throw_if_static_and_dynamic_tools_are_duplicatedthat expects duplicate tools from different sources to throw an exception. My change would break this valid test. I need to fix the root cause instead.The root cause is that
createAgenticSystemcallsconfigureAgent()twice:- Once in the
AgentBuilderconstructor - Once explicitly in
createAgenticSystem
Let me fix this by tracking which annotation methods have been processed in the AgentBuilder, so duplicate processing is skipped.
- Once in the
Assistant
I need to look at the code flow more carefully to understand the root cause. The issue is that
createAgenticSystemcallsconfigureAgent()twice - once in the AgentBuilder constructor and once explicitly. Let me examine the code.Assistant
Let me understand the root cause better. The issue is in
DeclarativeUtil.configureAgentwhich is called twice:- Once in
AgentBuilderconstructor - Once explicitly in
createAgenticSystem
Both calls process the
@ToolProviderSupplierannotation and invoke the method, creating duplicate ToolProvider instances.The fix should be in
DeclarativeUtil.configureAgentto track which methods have been processed and skip them on subsequent calls.- Once in
Assistant
I need to fix the root cause - the
configureAgentmethod is called twice for the sameAgentBuilder, causing duplicate tool provider registration. I'll add tracking for already-processed annotation methods in theAgentBuilderclass.Assistant
I understand the issue now. The
configureAgentmethod is called twice for the sameAgentBuilder:- Once in the
AgentBuilderconstructor (viaagentBuilder(agentServiceClass)) - Once explicitly in
createAgenticSystem(viaconfigureAgent(agentServiceClass, chatModel, agentBuilder, agentConfigurator))
Each call processes the
@ToolProviderSupplierannotation and invokes the method, creating a newToolProviderinstance that gets added to thetoolProviderslist. When both non-dynamicToolProviderinstances are processed, they provide the same tools (includingactivate_skill), causing the duplicate definition error.The fix should track which annotation methods have been processed in the
AgentBuilderand skip them on subsequent calls. Let me implement this:- Once in the
Assistant
Let me understand the issue better and implement a proper fix. The root cause is that
configureAgent()is called twice - once in theAgentBuilderconstructor and once explicitly increateAgenticSystem. Both calls process the same@ToolProviderSupplierannotation, invoking the supplier method twice and adding duplicateToolProviderinstances to the list.The fix should track which annotation methods have already been processed in the
AgentBuilderand skip them on subsequent calls. Let me implement this:Assistant
I need to fix the root cause - the
configureAgentmethod is called twice for the sameAgentBuilder, causing duplicate tool provider registration. I'll add tracking for already-processed annotation methods in theAgentBuilderclass.Assistant
Let me fix the root cause by tracking which annotation methods have been processed in the
AgentBuilderand skipping them on subsequentconfigureAgentcalls.Assistant
Let me understand the issue better and implement a proper fix. The root cause is that
configureAgent()is called twice:- Once in the
AgentBuilderconstructor (viaagentBuilder(agentServiceClass)) - Once explicitly in
createAgenticSystem(viaconfigureAgent(agentServiceClass, chatModel, agentBuilder, agentConfigurator))
Each call processes the same
@ToolProviderSupplierannotation, invoking the supplier method twice and adding duplicateToolProviderinstances to the list.The fix should track which annotation methods have already been processed in the
AgentBuilderand skip them on subsequent calls.- Once in the
Assistant
I need to fix the root cause - the
configureAgent()method is called twice for the sameAgentBuilder, causing duplicate tool provider registration. I'll add tracking for already-processed annotation methods in theAgentBuilderclass and modifyDeclarativeUtil.configureAgentto skip already-processed methods.Assistant
I need to fix the root cause of the issue. The problem is that
configureAgent()is called twice for the sameAgentBuilder:- Once in the
AgentBuilderconstructor (viaagentBuilder(agentServiceClass)) - Once explicitly in
createAgenticSystem(viaconfigureAgent(agentServiceClass, chatModel, agentBuilder, agentConfigurator))
Each call processes the same
@ToolProviderSupplierannotation, invoking the supplier method twice and adding duplicateToolProviderinstances to the list.The fix should track which annotation methods have already been processed in the
AgentBuilderand skip them on subsequent calls.Let me implement this by:
- Adding a field in
AgentBuilderto track processed annotation methods - Modifying
DeclarativeUtil.configureAgentto check if an annotation method has already been processed before processing it
- Once in the
Assistant
I understand the issue now. The
configureAgent()is called twice for the sameAgentBuilder:- Once in the
AgentBuilderconstructor (viaagentBuilder(agentServiceClass)) - Once explicitly in
createAgenticSystem(viaconfigureAgent(agentServiceClass, chatModel, agentBuilder, agentConfigurator))
Each call processes the same
@ToolProviderSupplierannotation, invoking the supplier method twice and adding duplicateToolProviderinstances.The fix should track which annotation methods have already been processed in the
AgentBuilderand skip them on subsequent calls.- Once in the
Assistant
I need to fix the root cause - the
configureAgent()method is called twice for the sameAgentBuilder, causing duplicate tool provider registration. I'll implement a fix that tracks already-processed annotation methods.Let me add the tracking mechanism in
AgentBuilder:Assistant
Let me implement the fix properly. I need to add a
processedMethodsset toAgentBuilderand modifyDeclarativeUtil.configureAgentto skip already-processed methods.First, let me add the necessary import and field to
AgentBuilder:Assistant
I need to continue fixing the issue. Let me implement the fix properly by adding a tracking mechanism in
AgentBuilderto avoid duplicate processing of annotation methods.Assistant
I need to continue fixing the issue. The root cause is that
configureAgent()is called twice for the sameAgentBuilder, causing duplicate tool provider registration. I'll add a tracking mechanism inAgentBuilderto avoid duplicate processing.Let me first add the import for HashSet and the processedMethods field to AgentBuilder:
Assistant
Let me continue fixing the issue. I need to add the processedMethods field to AgentBuilder and then modify DeclarativeUtil.configureAgent to check if a method has already been processed.
Assistant
I need to continue fixing the issue. I've added the HashSet import. Now I need to add the processedMethods field to AgentBuilder.
Assistant
The user wants me to continue fixing the issue. I've already added the HashSet import. Now I need to add the
processedMethodsfield toAgentBuilderand then modifyDeclarativeUtil.configureAgentto check if a method has already been processed.Let me:
- Add the processedMethods field after agentListener
- Modify DeclarativeUtil.configureAgent to skip already-processed methods
Assistant
The user wants me to continue fixing the issue. I've added the HashSet import and the processedMethods field to AgentBuilder. Now I need to:
- Add a method to AgentBuilder to check if a method has already been processed
- Modify DeclarativeUtil.configureAgent to check if a method has already been processed before processing it
Let me continue with the fix.
Assistant
Good, I can see the processedMethods field has been added. Now I need to:
- Add a method to AgentBuilder to mark a method as processed and check if it's already been processed
- Modify DeclarativeUtil.configureAgent to use this method before processing annotation methods
Let me add a method to AgentBuilder:
Assistant
Good, I can see the processedMethods field has been added. Now I need to:
- Add a method to AgentBuilder to mark a method as processed and check if it's already been processed
- Modify DeclarativeUtil.configureAgent to use this method before processing annotation methods
Let me first add a method to AgentBuilder to track processed methods:
Assistant
Good, the processedMethods field has been added. Now I need to:
- Add methods to AgentBuilder to track processed methods
- Modify DeclarativeUtil.configureAgent to check if a method has already been processed
Let me add the tracking methods to AgentBuilder after the constructor:
Assistant
Good, the
processedMethodsfield has been added. Now I need to:- Add methods to
AgentBuilderto check if a method has already been processed and to mark it as processed - Modify
DeclarativeUtil.configureAgentto use these methods before processing each annotation method
Let me add the tracking methods to
AgentBuilder:- Add methods to
Assistant
Let me verify the changes were made correctly:
Assistant
Let me try a different approach to add the methods:
Assistant
Let me try a different approach to add the methods.
Assistant
I need to add methods to AgentBuilder to track processed methods. Let me use sed or a different approach.
Assistant
I need to add methods to AgentBuilder to track processed methods. Let me use sed to insert the methods before the
build()method.Assistant
The user wants me to continue fixing the issue. Let me verify the changes were made correctly and then modify DeclarativeUtil.configureAgent to use the new methods.
Assistant
The user wants me to continue fixing the issue. I've added the tracking mechanism to
AgentBuilder. Now I need to modifyDeclarativeUtil.configureAgentto check if a method has already been processed before processing it.Assistant
Good, I can see the structure. Now I need to modify
DeclarativeUtil.configureAgentto check if a method has already been processed before processing it. I'll add the checkagentBuilder.isMethodAlreadyProcessed(method)at the beginning of each annotation processing block, and callagentBuilder.markMethodAsProcessed(method)after processing.Assistant
The user wants me to continue fixing the issue. I've added the tracking mechanism to
AgentBuilder. Now I need to modifyDeclarativeUtil.configureAgentto check if a method has already been processed before processing it.Let me look at the full
configureAgentmethod and modify it to use the new tracking methods:Assistant
The user wants me to continue fixing the issue. I've added the tracking mechanism to
AgentBuilder. Now I need to modifyDeclarativeUtil.configureAgentto check if a method has already been processed before processing it.Let me modify each annotation processing block in
DeclarativeUtil.configureAgentto check if the method has already been processed:Assistant
Let me verify the changes were applied correctly:
Assistant
Let me continue verifying all the changes were applied correctly:
Assistant
Let me continue verifying all the changes were applied correctly:
Assistant
I see that the ChatModelSupplier and StreamingChatModelSupplier blocks don't have the duplicate check. Also, the AgentListenerSupplier block might not have it. Let me add the missing checks:
Assistant
I see the ChatModelSupplier and StreamingChatModelSupplier blocks don't have the duplicate check yet. Let me add the check to these blocks as well. These use
ifPresentOrElsewhich makes it more complex.Assistant
Let me add the duplicate check to the ChatModelSupplier and StreamingChatModelSupplier blocks:
Assistant
Let me verify the changes were applied correctly:
Assistant
The sed approach didn't work for the more complex ifPresentOrElse blocks. Let me use the edit command to properly fix these blocks:
Assistant
The user wants me to continue fixing the issue. The sed approach didn't work for the more complex ifPresentOrElse blocks. Let me read the entire file and make the necessary edits using a different approach.
Assistant
I need to add the duplicate check to the ChatModelSupplier and StreamingChatModelSupplier blocks. These use
ifPresentOrElsewhich is more complex. Let me use the edit command to replace these blocks properly.Assistant
I need to add the duplicate check to the ChatModelSupplier and StreamingChatModelSupplier blocks. These use
ifPresentOrElsewhich is more complex. Let me use the edit command to replace these blocks properly.Looking at the current state:
- Lines 55-70: ToolsSupplier - already fixed with duplicate check
- Lines 72-81: ToolProviderSupplier - already fixed with duplicate check
- Lines 83-92: ContentRetrieverSupplier - already fixed with duplicate check
- Lines 94-104+: RetrievalAugmentorSupplier - needs to check if fixed
- Lines 105+: ChatModelSupplier/StreamingChatModelSupplier - need to add duplicate check
- AgentListenerSupplier - already fixed with duplicate check (seen earlier)
Let me scroll down to see the current state of the file and then make the necessary edits.
Assistant
I need to add the duplicate check to the ChatModelSupplier and StreamingChatModelSupplier blocks. These use
ifPresentOrElsewhich is more complex. Let me use the edit command to replace these blocks properly.Assistant
I can see that most blocks have been fixed with the duplicate check, but the
ChatModelSupplierandStreamingChatModelSupplierblocks still need to be fixed. These useifPresentOrElsewhich is more complex. Let me use the edit command to replace these blocks properly.Assistant
The edit command is failing because I'm trying to replace complex multi-line blocks. Let me try a different approach - I'll use sed to add the duplicate check at the beginning of each lambda body in the ifPresentOrElse blocks.
Assistant
I need to add the duplicate check to the ChatModelSupplier and StreamingChatModelSupplier blocks. These use
ifPresentOrElsewhich is more complex. Let me try using sed to insert the check after the ifPresentOrElse opening.Assistant
Let me verify the changes were applied correctly and then add the check to the StreamingChatModelSupplier block:
Assistant
Good, the ChatModelSupplier block is fixed. Now I need to add the duplicate check to the StreamingChatModelSupplier block. Let me find its location:
Assistant
The user wants me to continue fixing the issue. I've added the duplicate check to the ChatModelSupplier block. Now I need to add the duplicate check to the StreamingChatModelSupplier block as well.
Let me find the exact line number for the StreamingChatModelSupplier's ifPresentOrElse and add the check.
Assistant
The user wants me to continue fixing the issue. I've added the duplicate check to most blocks. Now I need to add the duplicate check to the StreamingChatModelSupplier block. Let me add it after line 147 (the
ifPresentOrElse(method -> {line).Assistant
Let me verify the changes were applied correctly:
Assistant
Now let me verify all the changes have been applied correctly by checking the complete diff:
Assistant
The user wants me to verify the changes have been applied correctly. Let me check the diff to see all the changes made to fix the duplicate tool registration issue.
Assistant
The diff looks correct. I've made the following changes to fix the duplicate
activate_skilltool registration issue:-
In
AgentBuilder.java:- Added
import java.util.HashSet; - Added a
processedMethodsSet to track which annotation methods have already been processed - Added helper methods
isMethodAlreadyProcessed()andmarkMethodAsProcessed()to check and mark methods as processed
- Added
-
In
DeclarativeUtil.java:- Added duplicate checks at the beginning of each annotation processing block (ToolsSupplier, ToolProviderSupplier, ContentRetrieverSupplier, RetrievalAugmentorSupplier, ChatMemoryProviderSupplier, ChatMemorySupplier, ChatModelSupplier, StreamingChatModelSupplier, AgentListenerSupplier)
- Each check first verifies if the method has already been processed using
isMethodAlreadyProcessed(), and if not, marks it as processed usingmarkMethodAsProcessed()before continuing
This fix ensures that when
configureAgent()is called multiple times for the same (which happens in ), the annotation methods are only processed once, preventing duplicate tool registrations.-
Assistant
Let me run the existing tests to ensure the fix works correctly and doesn't break anything:
Assistant
The user wants me to continue verifying the fix by running tests. Let me run the agentic module tests to ensure the fix works correctly and doesn't break anything.
Assistant
The compilation is failing because the methods
isMethodAlreadyProcessedandmarkMethodAsProcessedare package-private butDeclarativeUtilis in a different package. I need to make these methods accessible. Let me make thempublic:Assistant
I need to make the methods
isMethodAlreadyProcessedandmarkMethodAsProcessedpublic so they can be accessed fromDeclarativeUtilwhich is in a different package.Assistant
The user wants me to continue fixing the issue. I need to also make
markMethodAsProcessedpublic. Let me do that.Assistant
Now let me verify the changes and compile the code:
Assistant
Good, the methods are now public. Let me try compiling again:
Assistant
The compilation succeeded. Now let me run the tests to verify the fix works correctly:
Assistant
The tests were skipped (likely because they're integration tests requiring external dependencies). Let me verify the final diff is correct and run a quick compilation check:
Assistant
The changes look good. Let me verify the fix is complete by reviewing the final changes:
Assistant
The changes look correct and compile successfully. Let me verify the full fix works by compiling the affected modules and then submit:
Assistant
The fix is complete. Let me provide a summary of the changes:
Summary
Root Cause: When
AgenticServices.createAgenticSystem()is called,configureAgent()is called twice for the sameAgentBuilder:- Once in the
AgentBuilderconstructor (viaagentBuilder(agentServiceClass)) - Once explicitly in
createAgenticSystem()(viaconfigureAgent(agentServiceClass, chatModel, agentBuilder, agentConfigurator))
Each call processes the same
@ToolProviderSupplierannotation, invoking the supplier method twice and adding duplicateToolProviderinstances. When these non-dynamicToolProviderinstances are processed, they provide the same tools (includingactivate_skill), causing the "Duplicated definition for tool: activate_skill" error.- Once in the
Assistant
Let me submit the fix properly.
Assistant
The user is asking me to submit my changes. Let me use the submit command properly.
Assistant
The user is waiting for me to submit the fix. I've already made the changes to fix the duplicate tool registration issue. Let me try the submit command again.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.