AgentScope Java: Unlock Multi‑Agent AI Development Without Leaving Java
This article introduces AgentScope Java, a multi‑agent development framework that lets Java developers build intelligent assistants and collaborative agents with built‑in reasoning, tool use, memory, RAG, and Spring Boot integration, providing production‑grade performance and easy setup.
What Is AgentScope?
AgentScope is an open‑source multi‑agent development framework from Alibaba Tongyi Lab. It follows an "agent‑centric programming" model that turns large language models (LLMs) into autonomous, collaborative AI workers capable of planning, tool usage, and memory management. Both Java and Python versions are fully feature‑compatible, eliminating cross‑language friction.
AgentScope vs. Spring AI Alibaba
AgentScope Java is designed for building autonomous assistants that can plan, retrieve information, and invoke tools. Spring AI Alibaba is intended for quickly adding AI capabilities to an existing Spring project. The two frameworks serve different development goals.
Key Highlights
Self‑Control with ReAct : Agents decide when and which tools to use, with safety interrupts and human‑in‑the‑loop hooks to prevent undesired actions.
Production‑Grade Tools : Built‑in PlanNotebook for task decomposition, structured output parsers that map directly to Java POJOs, and long‑term memory with semantic search (supports Milvus, DashVector, etc.).
Extensible Ecosystem : Native support for MCP context protocol and A2A distributed multi‑agent protocol, enabling plug‑and‑play integration with services via Nacos discovery.
RAG Capability : Knowledge module provides end‑to‑end retrieval‑augmented generation, handling PDF/Word/Markdown ingestion, chunking, vectorization, and storage.
High Performance : Built on Project Reactor for non‑blocking, high‑concurrency workloads, ready for production from demo to deployment.
Quick Start
Add the all‑in‑one Maven dependency (or Gradle equivalent) and the Spring Boot starter if needed:
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-spring-boot-starter</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java</artifactId>
</dependency>Basic Agent Example
Create a QwenPlus model, define an agent with a system prompt, and send a message:
// Create QwenPlus model
DashScopeChatModel model = DashScopeChatModel.builder()
.apiKey(apiKey)
.modelName("qwen-plus")
.build();
// Create the agent
ReActAgent agent = ReActAgent.builder()
.name("AI Assistant")
.sysPrompt("You are a friendly professional AI assistant that answers in one sentence.")
.model(model)
.build();
// Send a query and print the response
Msg response = agent.call(Msg.builder().textContent("Explain AI in one sentence").build()).block();
System.out.println(response.getTextContent());Multi‑Turn Conversation with Memory
AgentScope automatically manages conversation memory, allowing continuous dialogs without manually passing history:
DashScopeChatModel model = DashScopeChatModel.builder()
.apiKey(apiKey)
.modelName("qwen-plus")
.build();
ReActAgent agent = ReActAgent.builder()
.name("AI Assistant")
.sysPrompt("You are a friendly professional AI assistant that answers in one sentence.")
.model(model)
.build();
List<String> questions = new ArrayList<>();
questions.add("My name is Zhang San");
questions.add("I am 25 years old");
questions.add("Summarize my info");
for (String q : questions) {
Msg res = agent.call(Msg.builder().textContent(q).build()).block();
System.out.println("Q: " + q + "
A: " + res.getTextContent() + "
");
}Multi‑Agent Collaboration
Define different agents with specialized roles (e.g., planner, executor, reviewer) and let them cooperate to solve complex tasks, mimicking a small team workflow.
Project Links
Official repository: https://github.com/agentscope-ai/agentscope-java
Supported models include Tongyi Qianwen, DeepSeek, GPT‑4, and local Ollama models.
Architecture Digest
Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
