Class AgentSpecLoader
java.lang.Object
io.agentscope.harness.agent.subagent.AgentSpecLoader
Loads
SubagentDeclaration instances from Markdown files with YAML front matter placed
in the subagents/ directory of a workspace.
File naming: the filename (without the .md extension) becomes the
subagent's name / agent-id. The front matter must not contain a name field.
Scan strategy: only direct children of the given directory are scanned (non-recursive) to prevent accidentally loading files that live inside a definition workspace that happens to be stored under the same parent.
File format:
--- description: Reviews code for security and performance issues. workspace: mode: isolated # isolated | shared (default: isolated) path: ./defs/reviewer # optional; relative to mainWorkspace, or absolute model: qwen3-max # optional model override maxIters: 12 # optional (default 10) tools: [read_file, grep_files, edit_file] # optional allowlist --- # Inline body (only when workspace.path is absent) You are a code reviewer...
Rules:
descriptionis required.- When
workspace.pathis present, the Markdown body must be blank; the subagent's system prompt is read from<workspace.path>/AGENTS.mdat runtime. - When
workspace.pathis absent, the Markdown body (if any) becomes the inlineSubagentDeclaration.getInlineAgentsBody().
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<SubagentDeclaration>loadFromDirectory(Path subagentsDir, Path mainWorkspace) static SubagentDeclarationloadFromFile(Path filePath, Path mainWorkspace) Parses a single Markdown declaration file.static List<SubagentDeclaration>loadFromFilesystem(AbstractFilesystem filesystem, io.agentscope.core.agent.RuntimeContext runtimeContext, Path mainWorkspace) Loads subagent declarations via theAbstractFilesystem, respecting the supplied runtime context's namespace isolation.static List<SubagentDeclaration>loadFromFilesystem(AbstractFilesystem filesystem, Path mainWorkspace) Loads subagent declarations via theAbstractFilesystemusing an empty runtime context.static SubagentDeclarationParses markdown content with YAML front matter into aSubagentDeclaration.
-
Method Details
-
loadFromDirectory
- Parameters:
subagentsDir- thesubagents/directory to scanmainWorkspace- the parent workspace used to resolve relativeworkspace.pathvalues; may benull(relative paths will remain relative)- Returns:
- list of parsed declarations; never
null
-
loadFromFilesystem
public static List<SubagentDeclaration> loadFromFilesystem(AbstractFilesystem filesystem, Path mainWorkspace) Loads subagent declarations via theAbstractFilesystemusing an empty runtime context. Scanssubagents/for*.mdfiles using filesystem glob.Use
loadFromFilesystem(AbstractFilesystem, RuntimeContext, Path)when declarations are scoped to a calling user's namespace.- Parameters:
filesystem- the filesystem layer (applies namespace transparently)mainWorkspace- the parent workspace for resolving relative workspace paths; may benull- Returns:
- list of parsed declarations; never
null
-
loadFromFilesystem
public static List<SubagentDeclaration> loadFromFilesystem(AbstractFilesystem filesystem, io.agentscope.core.agent.RuntimeContext runtimeContext, Path mainWorkspace) Loads subagent declarations via theAbstractFilesystem, respecting the supplied runtime context's namespace isolation.- Parameters:
filesystem- the filesystem layer (applies namespace transparently)runtimeContext- the call context used to resolve namespace-scoped declarationsmainWorkspace- the parent workspace for resolving relative workspace paths; may benull- Returns:
- list of parsed declarations; never
null
-
loadFromFile
public static SubagentDeclaration loadFromFile(Path filePath, Path mainWorkspace) throws IOException Parses a single Markdown declaration file.- Parameters:
filePath- the.mdfile to parsemainWorkspace- workspace root used to resolve relativeworkspace.pathvalues; may benull- Returns:
- parsed declaration, or
nullif the file is malformed / missing required fields - Throws:
IOException
-
parse
Parses markdown content with YAML front matter into aSubagentDeclaration.- Parameters:
markdown- the full file contentname- the subagent name (derived from the filename, without.md)mainWorkspace- workspace root used to resolve relativeworkspace.pathvalues; may benull- Returns:
- parsed declaration, or
nullif the content is malformed
-