█

AI/TLDR

Buy me a coffee
Buy me a coffee

Agents-Flex

Modular Java framework for LLM calls, tool calling, durable agents, RAG, MCP and Text2SQL

Agent Frameworks & BuildersOpen source
Latest
v2.3.2
Updated
28 Oct 2026
Language
Java
License
Apache-2.0

What's new

v2.3.228 Oct 2026

Adds prompt-cache token tracking, OpenTelemetry agent-event spans and metrics aligned with the GenAI conventions, a SoMark OCR document-parsing adapter, and Serply and you.com web-search providers.

IN SHORT

What is Agents-Flex?

Agents-Flex is Modular Java framework for LLM calls, tool calling, durable agents, RAG, MCP and Text2SQL. Most modules run on JDK 8 or later, in plain Java, Spring Boot or other JVM stacks; the MCP module needs JDK 17. It sits in the Agent Frameworks & Builders category of the Agents & Automation tools and is open-source, written in Java and licensed Apache-2.0.

Updated Markdown version ↗

Overview

Agents-Flex is a lightweight AI application framework for the Java ecosystem, which the project positions as a counterpart to Spring AI. It organises LLM calls, tool calling, agents, RAG, vector stores, embeddings, image generation, audio, MCP, Skills, Text2SQL and related capabilities into separate Maven modules, so an application depends only on the pieces it uses and is not tied to a particular runtime or application framework. Most modules run on JDK 8 or later, in plain Java, Spring Boot or other JVM stacks; the MCP module needs JDK 17.

Provider differences sit behind unified interfaces — ChatModel, EmbeddingModel, ImageModel, RerankModel — with the same Prompt, options, interceptor and context mechanisms for blocking and streaming calls. Chat integrations cover OpenAI-compatible APIs, Qwen, Ollama, DeepSeek and LiteLLM, and the store module covers Redis, Qdrant, Chroma, Pgvector, MariaDB, Milvus, OpenSearch, Elasticsearch and others. Business methods become tools through @ToolDef/@ToolParam annotations or Tool.builder(), and ToolGroup attaches a set of tools only when the latest user message matches.

The Agents-Flex Agent Runtime demo: an agent configuration panel on the left, a chat in the middle where the agent asks the user to fill a generated form, and a live agent event stream on the right.
The project's full-stack Agent Runtime demo, showing a form-input pause and the live event stream.Agents-Flex docs ↗

For agents, AgentRunner advances a turn with tool calls, approval, suspension, resumption and persistence, backed by snapshot recovery and JDBC or Redis stores; subagents, file-system Skills with progressive disclosure, an MCP client (stdio, http-sse and http-stream) and an LLM Wiki tool that lets an agent browse a hierarchical knowledge tree build on the same abstractions. Production concerns — model routing, retry, load balancing, circuit breaking, OpenTelemetry observability and read-only SQL checks for Text2SQL — are built in. The project is Apache-2.0 licensed; v2.3.2 was released on October 28, 2026.

What it does

  • Unified ChatModel / EmbeddingModel / ImageModel / RerankModel abstractions with matching sync and streaming APIs
  • Annotation-based or programmatic tool calling, with ToolGroup to attach tools only when a prompt matches
  • Durable Agent runtime: snapshot recovery, tool approval, suspend/resume, middleware, event streams and JDBC/Redis persistence
  • RAG building blocks: document extraction, splitting, embeddings, ten-plus vector stores, retrieval and rerank
  • MCP client, file-system Skills with sandboxed execution, subagents, web search, Text2SQL and an LLM Wiki tool
  • Model routing, retry, load balancing, circuit breaking and OpenTelemetry observability; Spring Boot starter

Getting started

Agents-Flex is published to Maven under the com.agentsflex group. Most modules need JDK 8+, agents-flex-mcp needs JDK 17+.

Add the dependency

Use the aggregate BOM for plain Java, the starter for Spring Boot, or depend on single modules such as agents-flex-chat-openai and agents-flex-store-redis.

texttext
<dependency>
    <groupId>com.agentsflex</groupId>
    <artifactId>agents-flex-bom</artifactId>
    <version>2.3.2</version>
</dependency>

Call a model

This uses an OpenAI-compatible API; replace endpoint, model and apiKey with your own provider's values.

texttext
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);

Expose a method as a tool

Annotate a business method, register the class on a prompt, and run the tool calls the model asks for before asking again.

texttext
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";
    }
}

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());
}

Stream the answer

The same model streams through a listener.

texttext
chatModel.chatStream("Explain the Chain of Responsibility pattern in Java.", new StreamResponseListener() {
    @Override
    public void onMessage(StreamContext context, AiMessageResponse response) {
        System.out.print(response.getMessage().getContent());
    }
});

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Add LLM chat, tool calling and agents to an existing Java 8+ or Spring Boot service without changing frameworks
  • Build an enterprise knowledge base or customer-service bot on a vector store you already run
  • Run long agent tasks that must pause for human approval and resume from a snapshot
  • Offer natural-language data analysis over a database with read-only SQL checks

How Agents-Flex compares

Agents-Flex alongside other open-source agent frameworks & builders tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
DeepSeek Harness★ 289kDeepSeek AI's open-source agent harness (dsh), built on Cordis, where models, tools, skills, sessions, sandboxes, storage and the UI are all plugins composed through profiles.
AutoGPT★ 188kOne of the earliest autonomous agent projects, now a platform for building and running agents from reusable blocks and workflows.
DeerFlow★ 86kByteDance's open-source super agent harness built on LangGraph: skills, sub-agents, sandboxes, a filesystem and long-term memory for long-horizon research, coding and content tasks.
nanobot★ 50.5kLightweight self-hosted personal AI agent framework in Python, with a WebUI, terminal and chat-app channels, tools, long-term memory, MCP and scheduled automations.
LangGraph★ 45.6kA library from the LangChain team for building stateful, graph-based agent workflows with explicit control over steps, memory, and human-in-the-loop checkpoints.
Agno★ 43.3kA fast Python framework (formerly Phidata) for building agents with memory, tools, and multimodal inputs, plus a runtime for deploying them in production.
AgentGPT★ 36.3kAgentGPT lets you name a custom AI, give it a goal, and watch it plan tasks, run them, and learn from the results, all from a web browser.
Agents-Flex★ 1.1kModular Java framework for LLM calls, tool calling, durable agents, RAG, MCP and Text2SQL