This is the Java implementation of AgentScope. Please note that this project is still experimental and under active development.
Easy for beginners, powerful for experts.
- Transparent to Developers: Transparent is our FIRST principle. Prompt engineering, API invocation, agent building, workflow orchestration, all are visible and controllable for developers. No deep encapsulation or implicit magic.
- Realtime Steering: Native support for realtime interruption and customized handling.
- More Agentic: Support agentic tools management, agentic long-term memory control and agentic RAG, etc.
- Model Agnostic: Programming once, run with all models.
- LEGO-style Agent Building: All components are modular and independent.
- Multi-Agent Oriented: Designed for multi-agent, explicit message passing and workflow orchestration, NO deep encapsulation.
- Highly Customizable: Tools, prompt, agent, workflow, third-party libs & visualization, customization is encouraged everywhere.
AgentScope Java requires jdk 17 or higher.
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-core</artifactId>
<version>0.2.1</version>
</dependency>Start with a basic ReActAgent that replies to user queries!
public static void main(String[] args) {
Model model = DashScopeChatModel.builder()
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.modelName("qwen-max")
.build();
ReActAgent agent = ReActAgent.builder()
.name("hello-world-agent")
.sysPrompt("You are a helpful AI assistant. Be concise and friendly. " +
"When thinking through problems, use <thinking>...</thinking> tags to show your reasoning.")
.model(model)
.memory(new InMemoryMemory())
.formatter(new DashScopeChatFormatter())
.build();
Msg userMessage = Msg.builder()
.role(MsgRole.USER)
.textContent("Hello, please introduce yourself.")
.build();
Msg response = agent.reply(userMessage).block();
System.out.println("Agent Response: " + response.getTextContent());
}-
Define Tool
Define a tool class with methods annotated with
@Tool. Here's an exampleSimpleToolsclass with a time tool:public class SimpleTools { @Tool(name = "get_time", description = "Get current time string of a time zone") public String getTime(@ToolParam(description = "Time zone, e.g., Beijing") String zone) { LocalDateTime now = LocalDateTime.now(); return now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); } }
-
Register Tool to ReActAgent
Register the tool class through
Toolkitusing theregisterToolmethod:public static void main(String[] args) { Model model = DashScopeChatModel.builder() .apiKey(System.getenv("DASHSCOPE_API_KEY")) .modelName("qwen-max") .build(); Toolkit toolkit = new Toolkit(); toolkit.registerTool(new SimpleTools()); ReActAgent agent = ReActAgent.builder() .name("hello-world-agent") .sysPrompt("You are a helpful AI assistant.") .model(model) .toolkit(toolkit) .memory(new InMemoryMemory()) .formatter(new DashScopeChatFormatter()) .build(); Msg userMessage = Msg.builder() .role(MsgRole.USER) .textContent("Please tell me the current time.") .build(); Msg response = agent.reply(userMessage).block(); System.out.println("Agent Response: " + response.getTextContent()); }
- Create Message
- Create ReAct Agent
- Model
- Tool
- Memory
- Prompt Formatter
In the upcoming versions, AgentScope Java version will focus on improving the following features.
- Multi-modal
- Multi-Agent
- Tracing
- AgentScope Studio
AgentScope is released under Apache License 2.0.