agentscope-java README

The project's README from github.com/agentscope-ai/agentscope-java. As one markdown file: README.md.

AgentScope Logo

中文主页 | Documentation

discord docs Maven Central JDK 17+ license Ask DeepWiki

What is AgentScope Java 2.0?

AgentScope Java 2.0 is a production-ready framework for building distributed, enterprise-grade agents, providing essential abstractions that work with rising model capability and built-in support for long-running, safely-controlled agent execution.

agentscope

News

Community

Welcome to join our community on

Discord DingTalk WeChat

Quickstart

Installation

AgentScope Java requires JDK 17 or higher.

Maven

<dependency>
    <groupId>io.agentscope</groupId>
    <artifactId>agentscope-harness</artifactId>
    <version>2.0.1</version>
</dependency>

Model providers are shipped as separate extension modules in 2.0. Add the one you need — for example, DashScope:

<dependency>
    <groupId>io.agentscope</groupId>
    <artifactId>agentscope-extensions-model-dashscope</artifactId>
    <version>2.0.1</version>
</dependency>

Other options: agentscope-extensions-model-openai, agentscope-extensions-model-anthropic, agentscope-extensions-model-gemini, agentscope-extensions-model-ollama. See the Model docs for details.

If you only need a bare ReActAgent without workspace / persistence / sandbox, depend on agentscope-core alone.

Hello AgentScope!

Start your first agent with AgentScope Java 2.0:

import io.agentscope.core.agent.RuntimeContext;
import io.agentscope.core.message.UserMessage;
import io.agentscope.harness.agent.HarnessAgent;
import java.nio.file.Paths;

public class FirstAgent {
    public static void main(String[] args) {
        HarnessAgent agent = HarnessAgent.builder()
                .name("assistant")
                .sysPrompt("You are a helpful AI assistant.")
                // ModelRegistry resolves the string and reads the matching
                // API-key env var (e.g. OPENAI_API_KEY or DEEPSEEK_API_KEY)
                // automatically.
                // Examples: "openai:gpt-4.1", "openai:o3",
                // "deepseek:deepseek-v4-flash", "dashscope:qwen-plus",
                // "anthropic:claude-sonnet-4-7", "ollama:llama3"
                .model("dashscope:qwen-plus")
                // Or pass a ChatModel object directly:
                // .model(OpenAIChatModel.builder().model("gpt-4.1").build())
                .workspace(Paths.get(".agentscope/workspace"))
                .build();

        RuntimeContext ctx = RuntimeContext.builder()
                .sessionId("demo").userId("alice").build();

        // Blocking call
        agent.call(new UserMessage("Hello!"), ctx).block();

        // Or stream events for real-time UI rendering
        agent.streamEvents(new UserMessage("Summarize today in three bullets."), ctx)
                .doOnNext(event -> {
                    switch (event.getType()) {
                        case TEXT_BLOCK_DELTA -> System.out.print(
                                ((io.agentscope.core.event.TextBlockDeltaEvent) event).getDelta());
                        case TOOL_CALL_START -> System.out.println(
                                "\n[tool] " + ((io.agentscope.core.event.ToolCallStartEvent) event).getToolCallName());
                        default -> { }
                    }
                })
                .blockLast();
    }
}

AgentScope Service

AgentScope Service — an Agent Control Plane built on AgentScope Harness that provides:

agentscope-service-architecture.png

Key Design

AgentScope Java 2.0 is a major step up from a "build an agent" toolkit toward a complete platform for running agents in production. The improvements fall into three focus areas:

1 · Harness Engineering — built for long-running, complex tasks

A bare ReAct loop solves one reasoning turn. HarnessAgent layers engineering infrastructure on top of ReActAgent via Middleware and Toolkit channels — the reasoning core stays untouched, capabilities layer on:

2 · Enterprise-grade distributed deployment

Production agents must serve many tenants, run untrusted code safely, and survive rolling restarts. AgentScope 2.0 is built for stateless horizontal scaling:

3 · Foundation framework — a leaner, more developer-friendly core

Messages, events, and the extension model are smaller, more orthogonal — HITL and event streaming are part of how the framework runs, not add-ons:

For the complete architecture overview, see the documentation.

Contributing

We welcome contributions from the community! Please refer to our CONTRIBUTING.md for guidelines on how to contribute.

License

AgentScope is released under Apache License 2.0.

Contributors

All thanks to our contributors:

agentscope-java (agentscope-ai/agentscope-java)

Searching Database…

这是什么?AgentScope Java 2.0 是一个可用于生产环境的 Java 框架,用于构建分布式、企业级的 AI 智能体。它能安全地处理长时间运行的复杂任务,内置多智能体编排、沙箱隔离和人工介入控制。
它是单纯的智能体库,还是完整的平台?它采用分层设计:'agentscope-core' 提供一个基础的 ReActAgent;'HarnessAgent' 在其之上增加生产级工程能力(记忆、子智能体、中间件);可选的 AgentScope Service 则提供控制面板,用于管理跨不同运行时的大量智能体。
怎样把它加到 Java 项目里?添加 AgentScope 的 Maven 依赖,以及你需要的模型提供方扩展模块(例如 dashscope、openai、anthropic、gemini 或 ollama)。如果你只需要一个不含工作区、持久化或沙箱的基础 ReActAgent,只依赖 'agentscope-core' 即可。
开始之前需要安装什么?需要 JDK 17 或更高版本,以及用于构建的 Maven;如果要运行完整的分布式或企业级功能,还需要 Redis、MySQL、PostgreSQL、OSS 或 COS 等后端存储。
要完整运行这个项目需要什么?核心智能体代码很简单,但多租户隔离、安全沙箱和零停机会话恢复等企业级功能需要额外的基础设施:沙箱需要 Docker 或 Kubernetes,分布式状态则需要 Redis、MySQL 或 PostgreSQL。
这个项目面向哪些人?它面向的是需要构建生产级智能体的 Java 团队。这些智能体必须能跨副本扩展、服务多个租户,并安全地运行不可信的工具代码。它并不面向只想快速搭建单进程聊天机器人的业余爱好者。
AgentScope Service 是什么?它是一个可选的智能体控制平面和仪表盘,可在一个地方统一注册、发现和协调各个运行时中的智能体,包括 AgentScope、LangChain、ADK 以及 Claude/Qoder。
自我进化技能仓库是做什么的?成功的任务模式会自动保存为 Markdown 格式的“技能”,在各个会话之间共享,并按需加载。这样,智能体无需重新训练,就能在反复运行中不断改进。
这里的人工介入审批是怎样工作的?权限系统对每次工具调用有三种状态:允许、需要审批或拒绝。因此,敏感操作会暂停,并通过事件流提示人工确认后才会执行。
智能体能把工作委托给子智能体吗?可以。智能体在 Markdown 中声明子智能体的配置,并在运行时使用 'agentspawn'/'agentsend' 同步或在后台委托工作,事件会在各副本之间实时转发。
Size
57.4 MB
Stars
6K
Age
1y
Commits · 90 Days