Why AgentScope Java Beats Python for Multi‑Agent AI Development
AgentScope Java, Alibaba's open‑source multi‑agent framework, lets Java developers build autonomous assistants and collaborative agents with built‑in ReAct reasoning, RAG, memory, and enterprise‑grade integrations, offering a compelling alternative to Python‑centric AI stacks and Spring AI Alibaba.
What is AgentScope
AgentScope is an open‑source multi‑agent development framework from Alibaba Tongyi Lab that provides an agent‑centric programming model for Java. It treats large language models (LLMs) as controllable AI workers that can plan, invoke tools, and manage memory, matching the feature set of the Python version.
AgentScope vs Spring AI Alibaba
Both are Java AI frameworks but serve different purposes. AgentScope is designed for building autonomous assistants with planning, tool use, and long‑term memory. Spring AI Alibaba focuses on adding AI capabilities quickly to existing Spring applications. Choose AgentScope for full‑featured agent systems; choose Spring AI Alibaba for lightweight AI plug‑ins.
Key Highlights
ReAct reasoning‑action paradigm : Agents decide when and which tools to use, with safety interrupts and human‑in‑the‑loop hooks to prevent uncontrolled actions.
Built‑in production tools : PlanNotebook breaks complex goals into steps; a structured‑output parser maps results directly to Java POJOs; long‑term memory with semantic search enables personalized services.
Ecosystem integration : Native support for the MCP context protocol and the A2A distributed multi‑agent protocol lets agents call external services (e.g., GitHub, weather APIs) like plugging in a USB device. Nacos provides service discovery for micro‑service‑style agent collaboration.
RAG capabilities : The Knowledge module implements end‑to‑end retrieval‑augmented generation, handling PDF/Word/Markdown ingestion, text splitting, vectorization, and storage in Milvus or DashVector, delivering accurate answers from private documents.
High‑performance reactive core : Built on Project Reactor, the framework is non‑blocking and scales well under high concurrency, suitable for chatbots, data‑analysis assistants, or complex multi‑agent systems.
Quick Start
Add the all‑in‑one Maven dependency (or the Gradle equivalent) and, if needed, the Spring Boot starter.
<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>Create a simple ReAct agent that talks to the Qwen‑Plus model:
// Create QwenPlus model
DashScopeChatModel model = DashScopeChatModel.builder()
.apiKey(apiKey)
.modelName("qwen-plus")
.build();
// Build the ReAct agent
ReActAgent agent = ReActAgent.builder()
.name("AI助手")
.sysPrompt("你是友好专业的AI助手,擅长用一句话解答问题")
.model(model)
.build();
// Send a message and print the response
Msg response = agent.call(Msg.builder().textContent("一句话介绍人工智能").build()).block();
System.out.println(response.getTextContent());The output is a concise definition of artificial intelligence.
Memory and Multi‑Turn Dialogue
AgentScope automatically manages conversation memory, allowing agents to remember prior exchanges without explicit context handling. The following example shows a three‑turn interaction where the agent summarizes the user's name and age.
List<String> questions = new ArrayList<>();
questions.add("我叫张三");
questions.add("我今年25岁");
questions.add("总结一下我的信息");
for (String q : questions) {
Msg res = agent.call(Msg.builder().textContent(q).build()).block();
System.out.println("Q:" + q + "
A:" + res.getTextContent() + "
");
}Agent response: "姓名张三,年龄25岁,是不是超省心!"
Multi‑Agent Collaboration
Define distinct agents for planning, execution, and review to achieve division of labor. The planner creates a plan, the executor carries out steps, and the reviewer offers suggestions, forming a small AI team that tackles complex tasks.
// Planner agent
ReActAgent planner = ReActAgent.builder()
.name("规划专家")
.sysPrompt("你是一个经验丰富的项目规划专家,擅长制定计划和分解任务。")
.model(model)
.build();
// Executor agent
ReActAgent executor = ReActAgent.builder()
.name("执行专家")
.sysPrompt("你是一个执行专家,擅长将计划转化为具体的执行步骤。")
.model(model)
.build();Takeaways
Java developers can stay in their familiar stack while building multi‑agent applications.
Built‑in structured output, visual Studio, and hook system address the typical “uncontrollable AI output” pain point.
The A2A protocol plus Nacos integration defines an “AI micro‑service” architecture that aligns with enterprise development practices.
Project Links
Official repository: https://github.com/agentscope-ai/agentscope-java
Supported models include Tongyi Qwen, DeepSeek, GPT‑4, and any local Ollama‑compatible model.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Web Project
Focused on Java backend technologies, trending internet tech, and the latest industry developments. The platform serves over 200,000 Java developers, inviting you to learn and exchange ideas together. Check the menu for Java learning resources.
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.
