Agents-Flex: AI application development framework for Java
Agents-Flex is an AI application development framework for the Java ecosystem.
What it is · Main features · Getting started
What it is
Agents-Flex is an AI application development framework for the Java ecosystem. Agents-Flex is open source under the Apache License 2.0. Agents-Flex is suitable for building intelligent customer service, enterprise knowledge bases, natural-language data analysis, Agent workflows, model gateways, AI-assisted office tools, plugin-based tool systems, and Java services that need to connect to multiple model providers at the same time.
Core facts
Read by a script from the official API, not rewritten by a model.
- License
- Apache-2.0
- Languages
- Java
- Maintainer
- agents-flex
- Homepage
- https://agentsflex.com
- Verified
Main features
Core modules are compatible with Java 8 or newer and can run in plain Java, Spring Boot, or other JVM stacks.
ChatModel, EmbeddingModel, ImageModel, RerankModel, and other interfaces wrap provider-specific capabilities.
The chat module provides integrations for OpenAI-compatible APIs, Qwen, Ollama, DeepSeek, LiteLLM, and llmman.
The Tool Calling flow supports annotation-based scanning, programmatic tool building, tool execution, tool message feedback, and tool-level observability.
Business methods can be exposed as tools with annotations.
For larger tool sets, ToolGroup attaches tools and system instructions only when the latest user prompt matches.
Unmatched groups are omitted from the request body.
Interceptors can also be activated conditionally for each request.
The Agent runtime provides snapshot recovery, tool approval, version-safe persistence, middleware, and event streams.
McpClientManager connects to MCP Servers and wraps remote tools as Tool instances.
The agents-flex-mcp module supports stdio, http-sse, and http-stream transports.
The agents-flex-skills module supports file-system-based Skills, which are useful for packaging repeatable professional tasks such as code review, document generation, file processing, and local knowledge retrieval.
WikiTool exposes the available child Wikis of the root or current node to the model and reads content by path.
The agents-flex-text2sql module targets natural-language data analysis.
The agents-flex-text2sql module provides tools for listing data sources, inspecting table schemas, and executing SQL, with built-in read-only SQL checks, parameterized-query constraints, LIMIT control, tenant isolation, and audit extension points.
The framework includes model routing, allowing multiple model instances to be combined into one RoutedChatModel or RoutedEmbeddingModel.
Observability is based on OpenTelemetry and supports tracing and metrics collection.
Logging, OTLP, or custom exporters can be switched between with system properties.
Getting started
Most modules require JDK 8 or newer.
The agents-flex-mcp module requires JDK 17 or newer.
The build tool is Maven.
The current repository version is 2.3.2.
Plain Java projects can use the aggregate dependency.
Spring Boot projects use the starter.
Projects can also depend on only the modules they need.
In the OpenAI-compatible API example, endpoint, model, and apiKey are replaced with your own model service configuration.
After the tool is registered on a Prompt, the model can call it when needed.
<dependency>
<groupId>com.agentsflex</groupId>
<artifactId>agents-flex-bom</artifactId>
<version>2.3.2</version>
</dependency><dependency>
<groupId>com.agentsflex</groupId>
<artifactId>agents-flex-spring-boot-starter</artifactId>
<version>2.3.2</version>
</dependency><dependency>
<groupId>com.agentsflex</groupId>
<artifactId>agents-flex-chat-openai</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.agentsflex</groupId>
<artifactId>agents-flex-store-redis</artifactId>
<version>2.3.2</version>
</dependency>import com.agentsflex.core.model.chat.ChatModel;
import com.agentsflex.model.chat.openai.OpenAIChatConfig;
public class ChatDemo {
public static void main(String[] args) {
ChatModel chatModel = OpenAIChatConfig.builder()
.endpoint("https://ai.gitee.com")
.provider("GiteeAI")
.model("Qwen3-32B")
.apiKey(System.getenv("GITEE_API_KEY"))
.buildModel();
String reply = chatModel.chat("Introduce Agents-Flex in one sentence.");
System.out.println(reply);
}
}import com.agentsflex.core.model.chat.tool.annotation.ToolDef;
import com.agentsflex.core.model.chat.tool.annotation.ToolParam;
public class WeatherTools {
@ToolDef(name = "get_weather", description = "Query the weather for a given city")
public static String getWeather(
@ToolParam(name = "city", description = "City name", required = true) String city
) {
return city + ": sunny";
}
}import com.agentsflex.core.model.chat.response.AiMessageResponse;
import com.agentsflex.core.prompt.SimplePrompt;
SimplePrompt prompt = new SimplePrompt("What is the weather in Beijing today?");
prompt.addToolsFromClass(WeatherTools.class);
AiMessageResponse response = chatModel.chat(prompt);
if (response.hasToolCalls()) {
prompt.setToolMessages(response.executeToolCallsAndGetToolMessages());
System.out.println(chatModel.chat(prompt).getMessage().getContent());
}Who it is for
Agents-Flex is suitable for building intelligent customer service, enterprise knowledge bases, and model gateways, as well as Java services that need to connect to multiple model providers at the same time.
Sources
This page is written from the official sources below. Open them to check the original text.
- GitHub READMEhttps://github.com/agents-flex/agents-flexFetched
Verified ·
This page is written by AI from the official sources above and checked automatically. This site has not tested it. Found a mistake? Tell us.