Class SubagentDeclaration
A declaration binds to exactly one of two source modes:
- Definition workspace —
getWorkspacePath()points to a workspace directory containing at leastAGENTS.md. That file is used as the subagent's system-prompt body. Skills, knowledge, and MEMORY in the definition directory are available when theWorkspaceModeisWorkspaceMode.ISOLATED. - Remote HTTP —
getUrl()points to an AgentScope task HTTP server. No local definition workspace or inline body; the subagent runs out-of-process. Mutually exclusive with definition workspace and inline body.
The three source modes are mutually exclusive: at most one of SubagentDeclaration.Builder.workspace(Path),
a non-blank SubagentDeclaration.Builder.inlineAgentsBody(String), or a non-blank SubagentDeclaration.Builder.url(String)
may be set.
Workspace resolution follows the five-row decision table in WorkspaceMode.
The tools list, when non-empty, acts as an allowlist filter for inherited
parent tools: only inherited tools whose names appear in the list are kept. Child-local tool
registrations may still be added by the child builder.
Obtain instances via builder().
Example (programmatic):
SubagentDeclaration decl = SubagentDeclaration.builder()
.name("code-reviewer")
.description("Reviews code for security, performance, and readability issues.")
.workspace(Path.of("./defs/code-reviewer"))
.workspaceMode(WorkspaceMode.ISOLATED)
.model("qwen3-max")
.tools(List.of("read_file", "grep_files", "edit_file"))
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic enumWhether a declaration can be used as a top-level primary agent, only as a delegated subagent, or both. -
Method Summary
Modifier and TypeMethodDescriptionstatic SubagentDeclaration.Builderbuilder()Factory method for a new builder.Human-readable description; the main agent uses this to decide when to delegate.Recovery policy for orphaned tool calls in an automatically constructed local subagent.Per-type policy for exposing spawned instances of this subagent as user-addressable threads.Optional HTTP headers (e.g. auth) sent to the remote task server.Inline system-prompt body used whengetWorkspacePath()isnull.intDeprecated.getMode()TheSubagentDeclaration.Modeof this declaration.getModel()Optional model override (e.g.getName()Unique name / agent-id used to reference this subagent.Policy for resolving remote HITL (tool-confirmation) requests.Static attributes sent ascontext.attributeswith every remote submission, for the remote server to route on or expose to its agent.How much of the remote event stream to forward.intgetSteps()Maximum reasoning iterations (default 10).Optional sampling temperature override (e.g.getTools()Optional tool allowlist.getTopP()Optional nucleus-sampling override.getUrl()Base URL of the remote task server.Optional model variant identifier (e.g.Workspace resolution strategy.Path to the definition workspace directory (contains at leastAGENTS.md).booleanReturnstruewhen this declaration points at an external definition workspace.booleanisHidden()Whether this declaration should be hidden from the LLM's view of available subagents.booleanWhether the subagent inherits parent DENY permission rules.booleanWhether the subagent's session state should persist across parent calls.booleanisRemote()Returnstruewhen this declaration targets a remote task HTTP server.booleanWhether remote subagent events (text deltas, tool calls, confirmations) should be streamed back into the parent's live event stream when one is present.
-
Method Details
-
builder
Factory method for a new builder. -
getName
Unique name / agent-id used to reference this subagent. -
getDescription
Human-readable description; the main agent uses this to decide when to delegate. -
getWorkspaceMode
Workspace resolution strategy. Defaults toWorkspaceMode.ISOLATEDwhen not specified. -
getWorkspacePath
Path to the definition workspace directory (contains at leastAGENTS.md). Whennullthis declaration is in inline mode andgetInlineAgentsBody()provides the system prompt. -
getInlineAgentsBody
Inline system-prompt body used whengetWorkspacePath()isnull. May benullor blank if neither a definition workspace nor an inline body is provided. -
getModel
Optional model override (e.g."qwen3-max"or"openai:gpt-4o-mini"). Whennullor blank, the parent model is used. -
getMaxIters
Deprecated.since Phase A — usegetSteps(). Returns the same value; kept for source compatibility with callers built before thestepsfield existed.Maximum reasoning iterations. Defaults to 10. -
getSteps
public int getSteps()Maximum reasoning iterations (default 10). Replaces the historicalmaxItersfield. -
getTemperature
Optional sampling temperature override (e.g.0.0for deterministic compaction-like tasks,0.7for creative generation). Whennull, the parent'sGenerateOptions.getTemperature()applies unchanged. -
getTopP
Optional nucleus-sampling override. Whennull, the parent'sGenerateOptions.getTopP()applies unchanged. -
getVariant
Optional model variant identifier (e.g."thinking"for DashScope thinking-mode variants). Whennullor blank, no variant transform is applied; the parent's variant — if any — is inherited via builder copy. -
getMode
TheSubagentDeclaration.Modeof this declaration. Defaults toSubagentDeclaration.Mode.ALLwhen not specified — both spawnable and primary-capable. -
isHidden
public boolean isHidden()Whether this declaration should be hidden from the LLM's view of available subagents. Used for internal subagents (e.g. compaction, summary, title) that the orchestrator should not directly delegate to. -
isPersistSession
public boolean isPersistSession()Whether the subagent's session state should persist across parent calls. Whentrue, the spawn key is derived deterministically from (parentSessionId, agentId, label), enabling state recovery after process restarts. Whenfalse(default), a random UUID is used. -
isInheritParentPermissions
public boolean isInheritParentPermissions()Whether the subagent inherits parent DENY permission rules. Whentrue(default), all DENY rules from the parent's permission context are propagated to the child's permission engine at spawn time, preventing the child from circumventing parent-level restrictions. -
getExposeToUser
Per-type policy for exposing spawned instances of this subagent as user-addressable threads.Tri-state:
TRUE— always expose, regardless of what the LLM requests onagent_spawnFALSE— never expose (hard opt-out), overriding an LLMexpose_to_user=truenull(default) — no opinion; defer to the per-callRuntimeContextoverride and then the LLM'sexpose_to_userargument
This is overridden at runtime by a
RuntimeContextvalue keyedAgentSpawnTool#CTX_EXPOSE_TO_USER. SeeAgentSpawnToolfor the full resolution precedence. -
getEnablePendingToolRecovery
Recovery policy for orphaned tool calls in an automatically constructed local subagent.null(default) inherits the parent's setting;trueorfalseexplicitly overrides it. Remote subagents configure recovery on their own server. -
getTools
Optional tool allowlist. When non-empty, only inherited parent tools whose names are listed remain on the subagent's inherited toolkit. Empty means inherit all parent tools. -
getSkills
-
isRemote
public boolean isRemote()Returnstruewhen this declaration targets a remote task HTTP server. -
getUrl
Base URL of the remote task server. Non-blank only in remote mode. -
getHeaders
Optional HTTP headers (e.g. auth) sent to the remote task server. Never empty when non-null. -
isRemoteStreaming
public boolean isRemoteStreaming()Whether remote subagent events (text deltas, tool calls, confirmations) should be streamed back into the parent's live event stream when one is present. Defaults totruewhen unset. -
getRemoteStreamDetail
How much of the remote event stream to forward. Defaults toRemoteStreamDetail.FULL(lifecycle, tool calls, text and thinking deltas). UseRemoteStreamDetail.VERBOSEto mirror a local subagent's stream in full — block boundaries, tool output deltas, model calls with token usage and every other event — at the cost of more traffic. Only relevant whenisRemoteStreaming()is true. -
getRemoteAskPolicy
Policy for resolving remote HITL (tool-confirmation) requests. Defaults toRemoteAskPolicy.DENY, which auto-denies pending confirmations rather than leaving the remote task blocked indefinitely. -
getRemoteContextAttributes
Static attributes sent ascontext.attributeswith every remote submission, for the remote server to route on or expose to its agent.nullwhen unset; never empty otherwise. -
hasDefinitionWorkspace
public boolean hasDefinitionWorkspace()Returnstruewhen this declaration points at an external definition workspace.
-
getSteps().