Getting Started with AgentScope Java: Build Multi‑Agent LLM Applications Quickly

This guide introduces AgentScope, a multi‑agent framework for Java that brings ReAct reasoning, tool calling, memory management, RAG, and serverless capabilities to LLM‑powered applications, and provides step‑by‑step code examples for basic and advanced usage.

macrozheng
macrozheng
macrozheng
Getting Started with AgentScope Java: Build Multi‑Agent LLM Applications Quickly

Overview of AgentScope

AgentScope is a multi‑agent framework for building LLM‑based AI applications. It provides built‑in support for ReAct reasoning, tool invocation, memory management, and other core capabilities. Both Python and Java editions are available, and the Java version matches the Python feature set.

Design Comparison

AgentScope Java : Implements a native agentic paradigm with autonomous agents, ReAct loops, and complex multi‑agent collaboration.

Spring AI Alibaba : Focuses on workflow orchestration within the Spring AI ecosystem, suitable for inserting AI into predefined business flows.

Choose AgentScope Java for autonomous assistants that plan, retrieve information, and invoke tools; choose Spring AI Alibaba for simple AI chat or RAG integration in existing Spring services.

Key Features

Autonomous and Controllable : Uses the ReAct (reason‑action) paradigm, allowing agents to decide tool usage dynamically, with safety interrupts and human‑in‑the‑loop hooks.

Production‑Grade Tools : Includes PlanNotebook for task decomposition, structured output parsers that map responses to Java POJOs, and long‑term semantic memory.

Ecosystem Integration : Supports Model Context Protocol (MCP) and Agent‑to‑Agent (A2A) protocols, enabling micro‑service‑style discovery and interaction via Nacos.

Reactive Architecture : Built on Project Reactor for high‑performance, non‑blocking execution.

Quick Start

1. Add Dependency

<dependency>
  <groupId>io.agentscope</groupId>
  <artifactId>agentscope</artifactId>
  <version>1.0.4</version>
</dependency>

Gradle: implementation 'io.agentscope:agentscope:1.0.4' AgentScope works with any OpenAI‑compatible model (e.g., Qwen‑Plus, DeepSeek, GPT‑4) or local Ollama models.

2. Basic Agent and Single Turn

// Create Qwen‑Plus model
DashScopeChatModel model = DashScopeChatModel.builder()
        .apiKey(apiKey)
        .modelName("qwen-plus")
        .build();
// Build a ReAct agent
ReActAgent agent = ReActAgent.builder()
        .name("Assistant")
        .sysPrompt("You are a friendly, professional AI assistant.")
        .model(model)
        .build();
// Send a question
String question = "Please describe AI in one sentence.";
Msg response = agent.call(Msg.builder().textContent(question).build()).block();
System.out.println("Q: " + question);
System.out.println("A: " + response.getTextContent());

3. Multi‑Turn Conversation

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 r = agent.call(Msg.builder().textContent(q).build()).block();
    System.out.println("Q: " + q);
    System.out.println("A: " + r.getTextContent());
}

The agent retains context across turns.

4. Multi‑Agent Collaboration

ReActAgent planner = ReActAgent.builder().name("Planner").sysPrompt("You are a project planning expert.").model(model).build();
ReActAgent executor = ReActAgent.builder().name("Executor").sysPrompt("You are an execution expert.").model(model).build();
ReActAgent reviewer = ReActAgent.builder().name("Reviewer").sysPrompt("You are a review expert.").model(model).build();
String task = "Design a simple todo‑list management system";
Msg plan = planner.call(Msg.builder().textContent("Create a detailed plan for: " + task).build()).block();
Msg exec = executor.call(Msg.builder().textContent("Provide concrete steps based on:
" + plan.getTextContent()).build()).block();
Msg review = reviewer.call(Msg.builder().textContent("Evaluate the execution plan and suggest improvements:
" + exec.getTextContent()).build()).block();
System.out.println(plan.getTextContent());
System.out.println(exec.getTextContent());
System.out.println(review.getTextContent());

Advanced Capabilities

Knowledge‑Base Augmentation (RAG)

AgentScope includes a Knowledge module that handles document parsing (PDF, Markdown, Word), text chunking, embedding, and vector‑store storage (e.g., Milvus, DashVector). Agents automatically retrieve relevant context before answering, reducing hallucinations on private data.

MCP Protocol

The Model Context Protocol (MCP) standardizes external data access, allowing agents to call tools such as file systems, databases, or weather APIs without custom adapters. The A2A protocol enables cross‑server agent collaboration, turning agents into micro‑services.

Project Repository

GitHub: https://github.com/agentscope-ai/agentscope-java

JavaLLMMCPReActRAGAgentScopeMulti‑Agent
macrozheng
Written by

macrozheng

Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.