agentscope-java
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.
Install
mkdir -p .claude/skills/agentscope-java && curl -L -o skill.zip "https://mcp.directory/api/skills/download/4093" && unzip -o skill.zip -d .claude/skills/agentscope-java && rm skill.zipInstalls to .claude/skills/agentscope-java
About this skill
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 - All models are in
io.agentscope.core.model.*, NOTio.agentscope.model.*.
✅ 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.core.model.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
io.agentscope.model.*, FIX TOio.agentscope.core.model.*.
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.9</version>
</dependency>
</dependencies>
For local development (if working with source code):
<properties>
<agentscope.version>1.0.9</agentscope.version>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-core</artifactId>
<version>${agentscope.version}</version>
</dependency>
</dependencies>
⚠️ IMPORTANT: Version Selection
- Use
agentscope:1.0.9for production (stable, from Maven Central) - Use
agentscope-core:1.0.9only if you're developing AgentScope itself - NEVER use version
0.1.0-SNAPSHOT- this version doesn't exist
⚠️ CRITICAL: Common Dependency Mistakes
❌ WRONG - These artifacts don't exist:
<!-- DON'T use these - they don't exist -->
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-model-dashscope</artifactId> <!-- ❌ WRONG -->
</dependency>
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-model-openai</artifactId> <!-- ❌ WRONG -->
</dependency>
❌ WRONG - These versions don't exist:
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-core</artifactId>
<version>0.1.0-SNAPSHOT</version> <!-- ❌ WRONG - doesn't exist -->
</dependency>
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope</artifactId>
<version>0.1.0</version> <!-- ❌ WRONG - doesn't exist -->
</dependency>
✅ CORRECT - Use the stable release:
<!-- For production: use the stable release from Maven Central -->
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope</artifactId>
<version>1.0.9</version> <!-- ✅ CORRECT -->
</dependency>
Available Model Classes (all in agentscope-core)
// DashScope (Alibaba Cloud)
import io.agentscope.core.model.DashScopeChatModel;
// OpenAI
import io.agentscope.core.model.OpenAIChatModel;
// Gemini (Google)
import io.agentscope.core.model.GeminiChatModel;
// Anthropic (Claude)
import io.agentscope.core.model.AnthropicChatModel;
// Ollama (Local models)
import io.agentscope.core.model.OllamaChatModel;
Optional Extensions
<!-- Long-term memory with Mem0 -->
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-extensions-mem0</artifactId>
<version>${agentscope.version}</version>
</dependency>
<!-- RAG with Dify -->
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-extensions-rag-dify</artifactId>
<version>${agentscope.version}</version>
</dependency>
PROJECT OVERVIEW & ARCHITECTURE
AgentScope Java is a reactive, message-driven multi-agent framework built on Project Reactor and Java 17+.
Core Abstractions
Agent: The fundamental unit of execution. Most agents extendAgentBase.Msg: The message object exchanged between agents.Memory: Stores conversation history (InMemoryMemory,LongTermMemory).Toolkit&AgentTool: Defines capabilities the agent can use.Model: Interfaces with LLMs (OpenAI, DashScope, Gemini, Anthropic, etc.).Hook: Intercepts and modifies agent execution at various lifecycle points.Pipeline: Orchestrates multiple agents in sequential or parallel patterns.
Reactive Nature
Almost all operations (agent calls, model inference, tool execution) return Mono<T> or Flux<T>.
Key Design Principles
- Non-blocking: All I/O operations are asynchronous
- Message-driven: Agents communicate via immutable
Msgobjects - Composable: Agents and pipelines can be nested and combined
- Extensible: Hooks and custom tools allow deep customization
CODING STANDARDS & BEST PRACTICES
2.1 Java Version & Style
Target Java 17 (LTS) for maximum compatibility:
- Use Java 17 features (Records, Switch expressions, Pattern Matching for instanceof,
var, Sealed classes) - AVOID Java 21+ preview features (pattern matching in switch, record patterns)
- Follow standard Java conventions (PascalCase for classes, camelCase for methods/variables)
- Use Lombok where appropriate (
@Data,@Builderfor DTOs/Messages) - Prefer immutability for data classes
- Use meaningful names that reflect domain concepts
⚠️ CRITICAL: Avoid Preview Features
// ❌ WRONG - Requires Java 21 with --enable-preview
return switch (event) {
case PreReasoningEvent e -> Mono.just(e); // Pattern matching in switch
default -> Mono.just(event);
};
// ✅ CORRECT - Java 17 compatible
if (event instanceof PreReasoningEvent e) { // Pattern matching for instanceof (Java 17)
return Mono.just(event);
} else {
return Mono.just(event);
}
2.2 Reactive Programming (Critical)
⚠️ NEVER BLOCK IN AGENT LOGIC
Blocking operations will break the reactive chain and cause performance issues.
Rules:
- ❌ Never use
.block()in agent logic (only inmainmethods or tests) - ✅ Use
Monofor single results (e.g.,agent.call()) - ✅ Use
Fluxfor streaming responses (e.g.,model.stream()) - ✅ Chain operations using
.map(),.flatMap(),.then() - ✅ Use
Mono.defer()for lazy evaluation - ✅ Use
Mono.deferContextual()for reactive context access
Example:
// ❌ WRONG - Blocking
public Mono<String> processData(String input) {
String result = externalService.call(input).block(); // DON'T DO THIS
return Mono.just(result);
}
// ✅ CORRECT - Non-blocking
public Mono<String> processData(String input) {
return externalService.call(input)
.map(this::transform)
.flatMap(this::validate);
}
2.3 Message Handling (Msg)
Create messages using the Builder pattern:
Msg userMsg = Msg.builder()
.role(MsgRole.USER)
.content(TextBlock.builder().text("Hello").build())
.name("user")
.build();
Content Blocks:
TextBlock: For text contentThinkingBlock: For Chain of Thought (CoT) reas
Content truncated.
More by agentscope-ai
View all skills by agentscope-ai →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversAutomate macOS tasks with AppleScript and JavaScript. Control apps, files, and system efficiently using macOS Automator'
Effortlessly manage Google Cloud with this user-friendly multi cloud management platform—simplify operations, automate t
TypeScript Refactoring offers advanced TypeScript/JavaScript code analysis and intelligent refactoring for seamless and
Run Python code online or compile Java programs easily with Code Runner. Test code in 30+ languages instantly in your br
Perplexity offers an AI powered coding assistant with persistent chat and expert programming help, integrating seamlessl
Electron Desktop Automation streamlines app testing with screenshots, console monitoring, project detection, and debuggi
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.