agentscope-java
Skill này làm gì
Skill là hướng dẫn Java để xây dựng agent với framework AgentScope. Skill dành cho lập trình viên Java xây dựng agent LLM, dùng công cụ và hệ thống nhiều agent.
Khi nào nên dùng
- ✓Khi bạn muốn viết một agent Java bằng framework AgentScope.
- ✓Khi bạn cần kết nối một mô hình ngôn ngữ hoặc công cụ với agent AgentScope.
- ✓Khi bạn muốn xây hệ thống nhiều agent bằng mã Java phản ứng.
Liên kết skill
https://github.com/agentscope-ai/agentscope-java/blob/main/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Viết một agent ReAct AgentScope bằng Java dùng công cụ thời tiết và mô hình DashScope, có xử lý lỗi.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill cung cấp cho agent một bộ quy tắc và mẫu API đúng cho AgentScope, như dùng kiểu phản ứng và đọc khóa từ biến môi trường. Sau đó agent viết mã Java theo các mẫu đó.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
When the user asks you to write AgentScope Java code, follow these instructions carefully.
CRITICAL RULES - NEVER VIOLATE THESE
🚫 ABSOLUTELY FORBIDDEN:
- NEVER use
.block()in example code - This is the #1 mistake. Only use.block()inmain()methods or test code when explicitly creating a runnable example. - NEVER use
Thread.sleep()- UseMono.delay()instead. - NEVER use
ThreadLocal- Use Reactor Context withMono.deferContextual(). - NEVER hardcode API keys - Always use
System.getenv(). - NEVER ignore errors silently - Always log errors and provide fallback values.
- NEVER use wrong import paths - Shared model interfaces are in
io.agentscope.core.model.*; provider models are inio.agentscope.extensions.model.<provider>.*.
✅ ALWAYS DO:
- Use
MonoandFluxfor all asynchronous operations. - Chain operations with
.map(),.flatMap(),.then(). - Use Builder pattern for creating agents, models, and messages.
- Include error handling with
.onErrorResume()or.onErrorReturn(). - Add logging with SLF4J for important operations.
- Use correct imports:
import io.agentscope.extensions.model.dashscope.DashScopeChatModel; - Use correct APIs (many methods don't exist or have changed):
toolkit.registerTool()NOTregisterObject()toolkit.getToolNames()NOTgetTools()event.getToolUse().getName()NOTgetToolName()result.getOutput()NOTgetContent()(ToolResultBlock)event.getToolResult()NOTgetResult()(PostActingEvent)toolUse.getInput()NOTgetArguments()(ToolUseBlock)- Model builder: NO
temperature()method, usedefaultOptions(GenerateOptions.builder()...) - Hook events: NO
getMessages(),getResponse(),getIterationCount(),getThinkingBlock()methods - ToolResultBlock: NO
getToolUseName()method, useevent.getToolUse().getName()instead - ToolResultBlock.getOutput() returns
List<ContentBlock>NOTString, need to convert - @ToolParam format: MUST use
@ToolParam(name = "x", description = "y")NOT@ToolParam(name="x")
WHEN GENERATING CODE
FIRST: Identify the context
- Is this a
main()method or test code? →.block()is allowed (but add a warning comment) - Is this agent logic, service method, or library code? →
.block()is FORBIDDEN
For every code example you provide:
- Check: Does it use
.block()? → If yes in non-main/non-test code, REWRITE IT. - Check: Are all operations non-blocking? → If no, FIX IT.
- Check: Does it have error handling? → If no, ADD IT.
- Check: Are API keys from environment? → If no, CHANGE IT.
- Check: Are imports correct? → If using provider models from
io.agentscope.core.model.*, FIX TOio.agentscope.extensions.model.<provider>.*.
Default code structure for agent logic:
// ✅ CORRECT - Non-blocking, reactive (use this pattern by default)
return model.generate(messages, null, null)
.map(response -> processResponse(response))
.onErrorResume(e -> {
log.error("Operation failed", e);
return Mono.just(fallbackValue);
});
// ❌ WRONG - Never generate this in agent logic
String result = model.generate(messages, null, null).block(); // DON'T DO THIS
Only for main() methods (add warning comment):
public static void main(String[] args) {
// ⚠️ .block() is ONLY allowed here because this is a main() method
Msg response = agent.call(userMsg).block();
System.out.println(response.getTextContent());
}
PROJECT SETUP
When creating a new AgentScope project, use the correct Maven dependencies:
Maven Configuration (pom.xml)
For production use (recommended):
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<!-- Use the latest stable release from Maven Central -->
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope</artifactId>
<version>1.0.12</version>
</dependency>
</dependencies>
For local development (if working with source code):
<properties>
<agentscope.version>1.0.12</agentscope.version>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-core</artifactId>
<version>${agentscope.version}</version>
</dependency>
<dependency>
<
Câu hỏi thường gặp
AgentScope là gì?
AgentScope là framework cho hệ thống nhiều agent, xây trên Project Reactor trong Java.
Khóa API nên đặt ở đâu?
Skill yêu cầu đọc khóa từ biến môi trường và không bao giờ ghi chúng vào mã.
Skill có bao gồm công cụ và hook không?
Có. Mô tả nhắc đến việc tích hợp công cụ và hook.
Chi tiết
Mô tả gốc của tác giả
Expert Java developer skill for AgentScope Java framework - a reactive, message-driven multi-agent system built on Project Reactor. Use when working with reactive programming, LLM integration, agent orchestration, multi-agent systems, or when the user mentions AgentScope, ReActAgent, Mono/Flux, Project Reactor, or Java agent development. Specializes in non-blocking code, tool integration, hooks, pipelines, and production-ready agent applications.
Độ phổ biến
- Sao GitHub
- 6.2k
- Vị trí xếp hạng
- #14380
- Giấy phép
- Apache-2.0
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
data-report
6.2kGiúp agent của bạn tóm tắt một bộ dữ liệu thành báo cáo có trung bình, tổng, khoảng giá trị và xu hướng, lưu dưới dạng tệp Markdown.
data-transform
6.2kGiúp agent của bạn chuyển đổi tệp dữ liệu giữa các định dạng như CSV và JSON, để dữ liệu có thể dùng trong công cụ khác.
git-changelog
6.2kGiúp agent của bạn viết changelog hoặc ghi chú phát hành từ lịch sử Git, được nhóm thành tính năng, sửa lỗi và thay đổi khác.
image-resize
6.2kGiúp agent của bạn thay đổi kích thước hoặc nén hàng loạt hình ảnh như JPEG, PNG và WebP, đồng thời giữ nguyên tỷ lệ.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.