跪拜 Guibai
← All articles
Backend

One Markdown File Is One Employee: The Orchestrator-Workers Pattern in AgentScope-Java

By Mk59878 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Multi-agent teams in Java now scale by editing markdown instead of rewiring code, which moves role composition from compile time to deployment time. The pattern also gives a concrete way to solve context pollution and temperature conflicts, the two failures that make a single agent unreliable for multi-stage work.

Summary

AgentScope-Java ships multi-agent orchestration as an orchestrator-workers pattern. A HarnessAgent plays editor-in-chief: it splits a request into stages, spawns the right worker for each stage, waits for the result, and merges everything into a final briefing. Workers are declared as markdown files under workspace/agents/. YAML front matter sets name, description, temperature, and an optional tools list; the file body is the agent's system prompt.

The pattern targets three limits of a single agent. Workers run in isolated contexts, so one role's intermediate reasoning does not leak into another's output. Different temperatures can be assigned per role: the demo content team uses outliner at 0.7, writer at 0.8, and reviewer at 0.3, giving both creative drafting and stable review in one pipeline. The editor carries only the workflow, not the domain expertise, and receives condensed results instead of raw dumps.

The agents/ directory is scanned at first inference, not at builder time, so a team can be changed by editing files between conversations. The framework gives HarnessAgent 21 built-in tools, including agent_spawn, agent_send, and agent_list; to the editor, delegating to a worker is just another tool call. A compaction setting of 30 trigger messages and 10 kept messages keeps long orchestration runs inside context limits, and AgentSpecLoader can validate declaration files in CI without starting an agent.

Takeaways
— In AgentScope-Java, placing a markdown file in the workspace's agents/ directory declares a sub-agent; no Java code changes are needed to add a role.
— The YAML front matter of an agent declaration defines name, description, temperature, and tools; the markdown body below it becomes the system prompt.
— The editor-in-chief routes tasks from the description field, so it should be written like a job description: responsibility plus the condition that triggers assignment.
— Sub-agents only get tools listed by name in their own front matter; tools registered in the parent Toolkit are not inherited automatically.
— The content-team demo uses outliner at temperature 0.7, writer at 0.8, and reviewer at 0.3.
— The editor is built with HarnessAgent.builder(), points workspace to .agentscope/workspace, and configures compaction to trigger at 30 messages and keep the latest 10.
— HarnessAgent comes with 21 built-in tools, including agent_spawn, agent_send, and agent_list; spawning a worker is an ordinary tool call from the editor's perspective.
— The agents/ directory is scanned at first inference, so declarations can be added or edited and take effect on the next conversation.
— AgentSpecLoader.loadFromDirectory(agentsDir, workspace) parses declaration files for unit testing, so CI can catch malformed markdown at build time.
— Static sub-agent declarations live in agents/, not subagents/; subagents/ is the runtime mechanism for dynamically generated sub-agents.
Conclusions

Declaring agents as files makes team composition a data operation. The scan at first inference means a role can be added, retuned, or removed without a rebuild, which changes how an orchestration system is operated in production.

Multi-agent orchestration here adds no new execution model: agent_spawn is just another tool in the ReAct loop. That keeps the same event-stream debugging and tool-call tracing that already work for single agents.

Isolated worker contexts plus condensed returns are what make the editor's own context manageable. The architecture controls information flow as much as it divides labor.

Explicit per-worker tool lists enforce least privilege, but they are easy to miss: a worker with no tools can only answer in text even though the parent has registered the tool.

Splitting temperature across roles is one of the most concrete multi-agent advantages: a single agent cannot be exploratory and strict at the same time, while a pipeline of roles can be both.

Concepts & terms
Orchestrator-workers pattern
A multi-agent architecture where one coordinator agent decomposes a task, delegates pieces to specialized worker agents, waits for their results, and assembles a final answer. Each worker keeps its own system prompt, temperature, tools, and isolated context.
HarnessAgent
AgentScope-Java's built-in agent class that automatically receives a set of orchestration tools. It can serve as an editor-in-chief and uses agent_spawn, agent_send, and agent_list to manage workers.
agent_spawn
A built-in AgentScope-Java tool that lets an orchestrator create and dispatch a sub-agent for a task. From the orchestrator's point of view, it is just a tool call inside the same ReAct loop used for single-agent work.
Front matter
The YAML metadata block at the top of an agent declaration markdown file. In AgentScope-Java, it defines the agent's name, description, temperature, and tools list, while the rest of the file is the system prompt.
Context compaction
A mechanism that compresses conversation history when the message count passes a threshold. In the demo, the editor triggers compaction at 30 messages and keeps the latest 10 to prevent context overflow during long orchestration runs.
AgentSpecLoader
A utility in AgentScope-Java that parses agent declaration files without starting an agent. It can validate markdown declarations in unit tests or CI before the files are loaded at runtime.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗