-
Notifications
You must be signed in to change notification settings - Fork 159
Make LLM providers pluggable via auto-configuration #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
arefbehboudi
merged 3 commits into
ClawRunr:main
from
MarcosLM11:feat/pluggable-providers
Jul 28, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| plugins { | ||
| id 'java-library' | ||
| id 'java-test-fixtures' | ||
| id("com.skillsjars.gradle-plugin") version "0.0.2" | ||
| } | ||
|
|
||
|
|
||
30 changes: 0 additions & 30 deletions
30
base/src/main/java/ai/javaclaw/providers/AgentProvider.java
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
base/src/testFixtures/java/ai/javaclaw/testsupport/AutoConfigurationImportsTestSupport.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package ai.javaclaw.testsupport; | ||
|
|
||
| import java.io.IOException; | ||
| import java.io.UncheckedIOException; | ||
| import java.net.URISyntaxException; | ||
| import java.net.URL; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.util.List; | ||
|
|
||
| public final class AutoConfigurationImportsTestSupport { | ||
|
|
||
| private static final String IMPORTS_RESOURCE = | ||
| "META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports"; | ||
|
|
||
| private AutoConfigurationImportsTestSupport() { | ||
| } | ||
|
|
||
| public static List<String> importedAutoConfigurations(Class<?> testClass) throws IOException { | ||
| URL resource = testClass.getClassLoader().getResource(IMPORTS_RESOURCE); | ||
| try { | ||
| Path path = Path.of(resource.toURI()); | ||
| return Files.readAllLines(path).stream() | ||
| .map(String::trim) | ||
| .filter(line -> !line.isEmpty()) | ||
| .toList(); | ||
| } catch (URISyntaxException e) { | ||
| throw new UncheckedIOException(new IOException(e)); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...hropic/src/main/java/ai/javaclaw/providers/anthropic/AnthropicAgentAutoConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package ai.javaclaw.providers.anthropic; | ||
|
|
||
| import ai.javaclaw.onboarding.AgentOnboardingProvider; | ||
| import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
| import org.springframework.context.annotation.Bean; | ||
|
|
||
| @AutoConfiguration | ||
| public class AnthropicAgentAutoConfiguration { | ||
|
|
||
| @Bean | ||
| @ConditionalOnMissingBean(AnthropicAgentOnboardingProvider.class) | ||
| public AgentOnboardingProvider anthropicAgentOnboardingProvider() { | ||
| return new AnthropicAgentOnboardingProvider(); | ||
| } | ||
| } | ||
2 changes: 0 additions & 2 deletions
2
...ropic/src/main/java/ai/javaclaw/providers/anthropic/AnthropicAgentOnboardingProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ai.javaclaw.providers.anthropic.AnthropicAgentAutoConfiguration | ||
| ai.javaclaw.providers.anthropic.AnthropticClaudeCodeConfiguration |
32 changes: 32 additions & 0 deletions
32
...ic/src/test/java/ai/javaclaw/providers/anthropic/AnthropicAgentAutoConfigurationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package ai.javaclaw.providers.anthropic; | ||
|
|
||
| import ai.javaclaw.onboarding.AgentOnboardingProvider; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.boot.autoconfigure.AutoConfigurations; | ||
| import org.springframework.boot.test.context.runner.ApplicationContextRunner; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| import static ai.javaclaw.testsupport.AutoConfigurationImportsTestSupport.importedAutoConfigurations; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class AnthropicAgentAutoConfigurationTest { | ||
|
|
||
| private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() | ||
| .withConfiguration(AutoConfigurations.of(AnthropicAgentAutoConfiguration.class)); | ||
|
|
||
| @Test | ||
| void registersOnboardingProvider() { | ||
| contextRunner.run(context -> { | ||
| assertThat(context).hasSingleBean(AgentOnboardingProvider.class); | ||
| assertThat(context.getBean(AgentOnboardingProvider.class).getId()).isEqualTo("anthropic"); | ||
| }); | ||
| } | ||
|
|
||
| @Test | ||
| void bothAutoConfigurationsAreRegisteredViaImportsFile() throws IOException { | ||
| assertThat(importedAutoConfigurations(AnthropicAgentAutoConfigurationTest.class)).contains( | ||
| AnthropicAgentAutoConfiguration.class.getName(), | ||
| AnthropticClaudeCodeConfiguration.class.getName()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...e/src/main/java/ai/javaclaw/providers/google/genai/GoogleGenAIAgentAutoConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package ai.javaclaw.providers.google.genai; | ||
|
|
||
| import ai.javaclaw.onboarding.AgentOnboardingProvider; | ||
| import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
| import org.springframework.context.annotation.Bean; | ||
|
|
||
| @AutoConfiguration | ||
| public class GoogleGenAIAgentAutoConfiguration { | ||
|
|
||
| @Bean | ||
| @ConditionalOnMissingBean(GoogleGenAIAgentOnboardingProvider.class) | ||
| public AgentOnboardingProvider googleGenAIAgentOnboardingProvider() { | ||
| return new GoogleGenAIAgentOnboardingProvider(); | ||
| } | ||
| } |
2 changes: 0 additions & 2 deletions
2
.../src/main/java/ai/javaclaw/providers/google/genai/GoogleGenAIAgentOnboardingProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ai.javaclaw.providers.google.genai.GoogleGenAIAgentAutoConfiguration |
31 changes: 31 additions & 0 deletions
31
...c/test/java/ai/javaclaw/providers/google/genai/GoogleGenAIAgentAutoConfigurationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package ai.javaclaw.providers.google.genai; | ||
|
|
||
| import ai.javaclaw.onboarding.AgentOnboardingProvider; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.boot.autoconfigure.AutoConfigurations; | ||
| import org.springframework.boot.test.context.runner.ApplicationContextRunner; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| import static ai.javaclaw.testsupport.AutoConfigurationImportsTestSupport.importedAutoConfigurations; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class GoogleGenAIAgentAutoConfigurationTest { | ||
|
|
||
| private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() | ||
| .withConfiguration(AutoConfigurations.of(GoogleGenAIAgentAutoConfiguration.class)); | ||
|
|
||
| @Test | ||
| void registersOnboardingProvider() { | ||
| contextRunner.run(context -> { | ||
| assertThat(context).hasSingleBean(AgentOnboardingProvider.class); | ||
| assertThat(context.getBean(AgentOnboardingProvider.class).getId()).isEqualTo("google.genai"); | ||
| }); | ||
| } | ||
|
|
||
| @Test | ||
| void autoConfigurationIsRegisteredViaImportsFile() throws IOException { | ||
| assertThat(importedAutoConfigurations(GoogleGenAIAgentAutoConfigurationTest.class)) | ||
| .contains(GoogleGenAIAgentAutoConfiguration.class.getName()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...iders/ollama/src/main/java/ai/javaclaw/providers/ollama/OllamaAgentAutoConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package ai.javaclaw.providers.ollama; | ||
|
|
||
| import ai.javaclaw.onboarding.AgentOnboardingProvider; | ||
| import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
| import org.springframework.context.annotation.Bean; | ||
|
|
||
| @AutoConfiguration | ||
| public class OllamaAgentAutoConfiguration { | ||
|
|
||
| @Bean | ||
| @ConditionalOnMissingBean(OllamaAgentOnboardingProvider.class) | ||
| public AgentOnboardingProvider ollamaAgentOnboardingProvider() { | ||
| return new OllamaAgentOnboardingProvider(); | ||
| } | ||
| } |
2 changes: 0 additions & 2 deletions
2
...ders/ollama/src/main/java/ai/javaclaw/providers/ollama/OllamaAgentOnboardingProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ai.javaclaw.providers.ollama.OllamaAgentAutoConfiguration |
31 changes: 31 additions & 0 deletions
31
...s/ollama/src/test/java/ai/javaclaw/providers/ollama/OllamaAgentAutoConfigurationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package ai.javaclaw.providers.ollama; | ||
|
|
||
| import ai.javaclaw.onboarding.AgentOnboardingProvider; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.boot.autoconfigure.AutoConfigurations; | ||
| import org.springframework.boot.test.context.runner.ApplicationContextRunner; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| import static ai.javaclaw.testsupport.AutoConfigurationImportsTestSupport.importedAutoConfigurations; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class OllamaAgentAutoConfigurationTest { | ||
|
|
||
| private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() | ||
| .withConfiguration(AutoConfigurations.of(OllamaAgentAutoConfiguration.class)); | ||
|
|
||
| @Test | ||
| void registersOnboardingProvider() { | ||
| contextRunner.run(context -> { | ||
| assertThat(context).hasSingleBean(AgentOnboardingProvider.class); | ||
| assertThat(context.getBean(AgentOnboardingProvider.class).getId()).isEqualTo("ollama"); | ||
| }); | ||
| } | ||
|
|
||
| @Test | ||
| void autoConfigurationIsRegisteredViaImportsFile() throws IOException { | ||
| assertThat(importedAutoConfigurations(OllamaAgentAutoConfigurationTest.class)) | ||
| .contains(OllamaAgentAutoConfiguration.class.getName()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...iders/openai/src/main/java/ai/javaclaw/providers/openai/OpenAIAgentAutoConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package ai.javaclaw.providers.openai; | ||
|
|
||
| import ai.javaclaw.onboarding.AgentOnboardingProvider; | ||
| import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
| import org.springframework.context.annotation.Bean; | ||
|
|
||
| @AutoConfiguration | ||
| public class OpenAIAgentAutoConfiguration { | ||
|
|
||
| @Bean | ||
| @ConditionalOnMissingBean(OpenAIAgentOnboardingProvider.class) | ||
| public AgentOnboardingProvider openAIAgentOnboardingProvider() { | ||
| return new OpenAIAgentOnboardingProvider(); | ||
| } | ||
| } |
2 changes: 0 additions & 2 deletions
2
...ders/openai/src/main/java/ai/javaclaw/providers/openai/OpenAIAgentOnboardingProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ai.javaclaw.providers.openai.OpenAIAgentAutoConfiguration |
31 changes: 31 additions & 0 deletions
31
...s/openai/src/test/java/ai/javaclaw/providers/openai/OpenAIAgentAutoConfigurationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package ai.javaclaw.providers.openai; | ||
|
|
||
| import ai.javaclaw.onboarding.AgentOnboardingProvider; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.boot.autoconfigure.AutoConfigurations; | ||
| import org.springframework.boot.test.context.runner.ApplicationContextRunner; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| import static ai.javaclaw.testsupport.AutoConfigurationImportsTestSupport.importedAutoConfigurations; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class OpenAIAgentAutoConfigurationTest { | ||
|
|
||
| private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() | ||
| .withConfiguration(AutoConfigurations.of(OpenAIAgentAutoConfiguration.class)); | ||
|
|
||
| @Test | ||
| void registersOnboardingProvider() { | ||
| contextRunner.run(context -> { | ||
| assertThat(context).hasSingleBean(AgentOnboardingProvider.class); | ||
| assertThat(context.getBean(AgentOnboardingProvider.class).getId()).isEqualTo("openai"); | ||
| }); | ||
| } | ||
|
|
||
| @Test | ||
| void autoConfigurationIsRegisteredViaImportsFile() throws IOException { | ||
| assertThat(importedAutoConfigurations(OpenAIAgentAutoConfigurationTest.class)) | ||
| .contains(OpenAIAgentAutoConfiguration.class.getName()); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.