跪拜 Guibai
← All articles
Backend

AgentScope-Java: Alibaba's Answer to Building AI Agents Without Leaving the JVM

By 苏三说技术 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Most production AI agent frameworks — LangChain, AutoGen, CrewAI — live in the Python ecosystem, forcing Java-heavy enterprises to either maintain a second language stack or build agent infrastructure from scratch. AgentScope-Java removes that friction by providing ReAct loops, tool calling, memory, and multi-agent orchestration inside the JVM, with native Spring Boot and Maven compatibility.

Summary

AgentScope-Java 2.0 delivers a dual-agent architecture: ReActAgent for lightweight reasoning loops and HarnessAgent for production workloads with workspaces, long-term memory, session persistence, and sandboxed tool execution. Tools are defined by annotating plain Java methods with @Tool, and multi-agent orchestration follows an orchestrator-workers pattern where a main agent delegates to sub-agents defined in markdown files or Java code. The framework also supports the Model Context Protocol (MCP), automatically discovering and registering tools from MCP servers declared in a single JSON config. Distributed deployment is native: swap the state backend from local files to Redis or PostgreSQL, and any replica can restore a user's full context. The project targets Java shops that want agent capabilities without splitting their stack or learning Python frameworks like LangChain or AutoGen.

Takeaways
AgentScope-Java 2.0 requires JDK 17+ and Maven 3.9+; core dependency is agentscope-harness 2.0.0.
ReActAgent implements a full Think→Act→Observe→Think loop for single-session, stateless tasks.
HarnessAgent adds workspaces, long-term memory, session persistence, context compaction, sandbox isolation, and sub-agent orchestration on top of ReActAgent.
Any Java method becomes an Agent-callable tool by annotating it with @Tool and @ToolParam, then registering it in a Toolkit.
Multi-agent collaboration uses an orchestrator-workers pattern: a main HarnessAgent delegates to sub-agents defined as markdown files under workspace/subagents/ or as SubagentDeclaration objects in Java.
MCP servers are declared in workspace/tools.json; the Agent auto-discovers and registers their tools at startup via stdio, SSE, or WebSocket transports.
Distributed deployment works by switching the state backend — local files for dev, Redis/MySQL/PostgreSQL for production — with no code changes.
AgentScope-Java complements Spring AI Alibaba rather than competing: AgentScope handles agent reasoning and orchestration, Spring AI Alibaba handles AI capability access and RAG.
Conclusions

AgentScope-Java is not a port of a Python framework; it was designed from scratch for the Java build chain, which means it avoids the impedance mismatch that plagues cross-language rewrites.

The file-driven sub-agent definition — markdown files with id, description, and sysPrompt — turns agent routing into a configuration problem rather than a coding problem, lowering the bar for non-developers to tune agent behavior.

MCP support means AgentScope agents inherit a growing ecosystem of pre-built tools (GitHub, filesystem, Postgres, Slack, Puppeteer) without writing any Java wrappers, which dramatically reduces integration time.

The framework's bet on HarnessAgent as the default production entry point acknowledges that most agent demos fail in production not because of reasoning quality but because of missing infrastructure: memory, sessions, sandboxing, and state recovery.

Concepts & terms
ReAct (Reasoning + Acting)
A prompting paradigm where an LLM alternates between thinking through a step and executing an action (like calling a tool), then observing the result before thinking again, forming a loop until the task is complete.
MCP (Model Context Protocol)
An open protocol introduced by Anthropic in 2024 that standardizes how LLM applications discover and invoke external tools, typically via local stdio processes or remote HTTP SSE/WebSocket servers.
HarnessAgent
AgentScope's production-grade agent wrapper that layers workspace management, long-term memory, session persistence, context compaction, sandbox isolation, and sub-agent orchestration on top of the base ReActAgent.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗