Installation
AgentScope Java requires JDK 17 or newer. Maven 3.9+ is recommended.Maven dependency
HarnessAgent is the recommended entry point — it packages workspace, long-term memory, session persistence, subagents, sandboxes, and other engineering capabilities into one builder. Depending on agentscope-harness pulls agentscope-core in transitively:
Substitute
${agentscope.version} with the latest version. See Release Notes for the latest version and full release details.ReActAgent APIs (no workspace / persistence / subagents / sandbox), agentscope-core is enough for the agent framework itself. Concrete model providers are separate: provider-specific chat models and formatters live in independent agentscope-extensions-model-* modules. The difference between ReActAgent and HarnessAgent is covered in Harness Architecture.
The quickstart below uses DashScope through .model("dashscope:qwen-plus"), so add the matching model extension as well:
agentscope-examples/documentation/pom.xml for a working example.
Your first agent
The example below usesHarnessAgent to demonstrate three things at once: workspace-driven persona (AGENTS.md), automatic session persistence (the second turn with the same sessionId remembers the first), and conversation compaction (over-threshold compaction + long-term facts distilled into MEMORY.md). The model id is passed as a string to .model(...) — ModelRegistry resolves it and reads the matching API-key env var automatically.
AgentState lives outside the workspace at ~/.agentscope/state/<agentId>/ by default — because state is a prerequisite for restoring the workspace itself (e.g. after a sandbox wipe), so it must not be entangled with workspace data. Restart the process with the same sessionId and the second turn still remembers the first.
After enough turns trip compaction, distilled facts first land in workspace/memory/YYYY-MM-DD.md, then a throttled background job merges them into MEMORY.md, which is injected into the system prompt on the next reasoning step.
Streaming reasoning and tool calls
Swapcall(...) for streamEvents(...) to receive incremental events — text deltas, tool calls, etc. — suitable for Web / TUI rendering:
Multi-user concurrency
The agent is stateless between calls — a single instance can handle requests from different users and sessions. PassuserId / sessionId via RuntimeContext and the agent automatically loads and isolates the corresponding conversation state:
(userId, sessionId) are automatically serialized (no concurrent writes to one session); calls to different sessions run in parallel. For full production patterns (Redis session, sandbox, skill repositories), see Going to Production.
Next steps
- Agent — full
ReActAgentAPI, builder fields,call/streamEvents/observe, human-in-the-loop,AgentStateStoreconfiguration - Harness Architecture — how
HarnessAgent’s capabilities cooperate, how state flows - Workspace —
AGENTS.md/MEMORY.md/skills//subagents//tools.jsondirectory layout and loading model - Filesystem — local + shell / shared store / sandbox deployment modes