SWE-Rebench v2 hard task
harbor run -t ibragim-badertdinov/langchain4j__langchain4j-5315harbor download ibragim-badertdinov/langchain4j__langchain4j-5315[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:
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.
Type: Function Name: createAgenticSystem Path: langchain4j-agentic/src/main/java/dev/langchain4j/agentic/AgenticServices.java Input: Class<T> 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.