SubagentDeclaration
public final class SubagentDeclaration
io/agentscope/harness/agent/subagent/SubagentDeclaration.java:66–701子智能体 Declaration,支持智能体之间的发现、委派与协作。位于 io.agentscope.harness.agent.subagent 包。核心成员包括 builder、getName、getDescription、getWorkspaceMode、getWorkspacePath、getInlineAgentsBody。
Declares a subagent: its identity, workspace resolution strategy, and optional capability allowlist.
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 Builder#workspace(Path),
a non-blank Builder#inlineAgentsBody(String), or a non-blank 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
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Mode | 枚举enum | 定义模式相关取值的枚举。 Whether a declaration can be used as a top-level primary agent, only as a delegated
subagent, or both. |
Builder | 类class | 构建器,用于构建并配置目标实例。 A class in io.agentscope.harness.agent.subagent that supports discovery, delegation and collaboration between agents. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static Builder builder()static | 用于新的构建器的工厂方法。 Factory method for a new builder. |
public String getName() | 获取名称。 Unique name / agent-id used to reference this subagent. |
public String getDescription() | 获取 `getDescription`。 Human-readable description; the main agent uses this to decide when to delegate. |
public WorkspaceMode getWorkspaceMode() | 获取工作区模式。 Workspace resolution strategy. |
public Path getWorkspacePath() | 获取工作区路径。 Path to the definition workspace directory (contains at least `AGENTS.md`). |
public String getInlineAgentsBody() | 获取 `getInlineAgentsBody`。 Inline system-prompt body used when `#getWorkspacePath()` is `null`. |
public String getModel() | 获取模型。 Optional model override (e.g. |
public int getMaxIters()deprecated | 获取最大迭代次数。 Maximum reasoning iterations. |
public int getSteps() | 获取步骤。 Maximum reasoning iterations (default 10). |
public Double getTemperature() | 获取 `getTemperature`。 Optional sampling temperature override (e.g. |
public Double getTopP() | 获取 `getTopP`。 Optional nucleus-sampling override. |
public String getVariant() | 获取 `getVariant`。 Optional model variant identifier (e.g. |
public Mode getMode() | 获取模式。 The `Mode` of this declaration. |
public boolean isHidden() | 判断是否隐藏。 Whether this declaration should be hidden from the LLM's view of available subagents. |
public boolean isPersistSession() | 判断是否 `isPersistSession`。 Whether the subagent's session state should persist across parent calls. |
public boolean isInheritParentPermissions() | 判断是否 `isInheritParentPermissions`。 Whether the subagent inherits parent DENY permission rules. |
public Boolean getExposeToUser() | 获取 `getExposeToUser`。 Per-type policy for exposing spawned instances of this subagent as user-addressable threads. |
public Boolean getEnablePendingToolRecovery() | 获取 `getEnablePendingToolRecovery`。 Recovery policy for orphaned tool calls in an automatically constructed local subagent. |
public List<String> getTools() | 获取工具。 Optional tool allowlist. |
public List<String> getSkills() | 获取技能。 Returns the skills. |
public boolean isRemote() | 判断是否远程。 Returns `true` when this declaration targets a remote task HTTP server. |
public String getUrl() | 远程任务服务端的基类 URL。 Base URL of the remote task server. |
public Map<String, String> getHeaders() | 获取请求头。 Optional HTTP headers (e.g. |
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. |
public RemoteStreamDetail getRemoteStreamDetail() | 获取远程流详情。 How much of the remote event stream to forward. |
public RemoteAskPolicy getRemoteAskPolicy() | 获取 `getRemoteAskPolicy`。 Policy for resolving remote HITL (tool-confirmation) requests. |
public Map<String, Object> getRemoteContextAttributes() | 获取远程上下文属性。 Static attributes sent as `context.attributes` with every remote submission, for the
remote server to route on or expose to its agent. |
public boolean hasDefinitionWorkspace() | 判断是否具有定义工作区。 Returns `true` when this declaration points at an external definition workspace. |
方法详情Method Detail
builder
public static Builder builder()
用于新的构建器的工厂方法。
Factory method for a new builder.
Builderio/agentscope/harness/agent/subagent/SubagentDeclaration.java:161–163getName
public String getName()
获取名称。
Unique name / agent-id used to reference this subagent.
Stringio/agentscope/harness/agent/subagent/SubagentDeclaration.java:166–168getDescription
public String getDescription()
获取 getDescription。
Human-readable description; the main agent uses this to decide when to delegate.
Stringio/agentscope/harness/agent/subagent/SubagentDeclaration.java:171–173getWorkspaceMode
public WorkspaceMode getWorkspaceMode()
获取工作区模式。
Workspace resolution strategy.
WorkspaceModeio/agentscope/harness/agent/subagent/SubagentDeclaration.java:179–181getWorkspacePath
public Path getWorkspacePath()
获取工作区路径。
Path to the definition workspace directory (contains at least AGENTS.md).
Pathio/agentscope/harness/agent/subagent/SubagentDeclaration.java:188–190getInlineAgentsBody
public String getInlineAgentsBody()
获取 getInlineAgentsBody。
Inline system-prompt body used when #getWorkspacePath() is null.
Stringio/agentscope/harness/agent/subagent/SubagentDeclaration.java:196–198getModel
public String getModel()
获取模型。
Optional model override (e.g.
Stringio/agentscope/harness/agent/subagent/SubagentDeclaration.java:204–206getMaxIters
public int getMaxIters()
获取最大迭代次数。
Maximum reasoning iterations.
intio/agentscope/harness/agent/subagent/SubagentDeclaration.java:214–217getSteps
public int getSteps()
获取步骤。
Maximum reasoning iterations (default 10).
intio/agentscope/harness/agent/subagent/SubagentDeclaration.java:220–222getTemperature
public Double getTemperature()
获取 getTemperature。
Optional sampling temperature override (e.g.
Doubleio/agentscope/harness/agent/subagent/SubagentDeclaration.java:229–231getTopP
public Double getTopP()
获取 getTopP。
Optional nucleus-sampling override.
Doubleio/agentscope/harness/agent/subagent/SubagentDeclaration.java:237–239getVariant
public String getVariant()
获取 getVariant。
Optional model variant identifier (e.g.
Stringio/agentscope/harness/agent/subagent/SubagentDeclaration.java:246–248getMode
public Mode getMode()
获取模式。
The Mode of this declaration.
Modeio/agentscope/harness/agent/subagent/SubagentDeclaration.java:254–256isPersistSession
public boolean isPersistSession()
判断是否 isPersistSession。
Whether the subagent's session state should persist across parent calls.
booleanio/agentscope/harness/agent/subagent/SubagentDeclaration.java:272–274isInheritParentPermissions
public boolean isInheritParentPermissions()
判断是否 isInheritParentPermissions。
Whether the subagent inherits parent DENY permission rules.
booleanio/agentscope/harness/agent/subagent/SubagentDeclaration.java:281–283getExposeToUser
public Boolean getExposeToUser()
获取 getExposeToUser。
Per-type policy for exposing spawned instances of this subagent as user-addressable threads.
Booleanio/agentscope/harness/agent/subagent/SubagentDeclaration.java:301–303getEnablePendingToolRecovery
public Boolean getEnablePendingToolRecovery()
获取 getEnablePendingToolRecovery。
Recovery policy for orphaned tool calls in an automatically constructed local subagent.
Booleanio/agentscope/harness/agent/subagent/SubagentDeclaration.java:310–312getTools
public List<String> getTools()
获取工具。
Optional tool allowlist.
List<String>io/agentscope/harness/agent/subagent/SubagentDeclaration.java:318–320getSkills
public List<String> getSkills()
获取技能。
Returns the skills.
List<String>io/agentscope/harness/agent/subagent/SubagentDeclaration.java:322–324isRemote
public boolean isRemote()
判断是否远程。
Returns true when this declaration targets a remote task HTTP server.
booleanio/agentscope/harness/agent/subagent/SubagentDeclaration.java:327–329getUrl
public String getUrl()
远程任务服务端的基类 URL。
Base URL of the remote task server.
Stringio/agentscope/harness/agent/subagent/SubagentDeclaration.java:334–336getHeaders
public Map<String, String> getHeaders()
获取请求头。
Optional HTTP headers (e.g.
Map<String, String>io/agentscope/harness/agent/subagent/SubagentDeclaration.java:342–344isRemoteStreaming
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.
booleanio/agentscope/harness/agent/subagent/SubagentDeclaration.java:351–353getRemoteStreamDetail
public RemoteStreamDetail getRemoteStreamDetail()
获取远程流详情。
How much of the remote event stream to forward.
RemoteStreamDetailio/agentscope/harness/agent/subagent/SubagentDeclaration.java:362–364getRemoteAskPolicy
public RemoteAskPolicy getRemoteAskPolicy()
获取 getRemoteAskPolicy。
Policy for resolving remote HITL (tool-confirmation) requests.
RemoteAskPolicyio/agentscope/harness/agent/subagent/SubagentDeclaration.java:371–373getRemoteContextAttributes
public Map<String, Object> getRemoteContextAttributes()
获取远程上下文属性。
Static attributes sent as context.attributes with every remote submission, for the remote server to route on or expose to its agent.
Map<String, Object>io/agentscope/harness/agent/subagent/SubagentDeclaration.java:380–382hasDefinitionWorkspace
public boolean hasDefinitionWorkspace()
判断是否具有定义工作区。
Returns true when this declaration points at an external definition workspace.
booleanio/agentscope/harness/agent/subagent/SubagentDeclaration.java:385–387嵌套类详情Nested Class Detail
Mode
public enum Mode定义模式相关取值的枚举。位于 io.agentscope.harness.agent.subagent 包。核心成员包括 PRIMARY、SUBAGENT、ALL。
Whether a declaration can be used as a top-level primary agent, only as a delegated subagent, or both.
The io.agentscope.harness.agent.subagent.DefaultAgentManager#createAgentIfPresent
path rejects spawn requests for #PRIMARY-only declarations so they can never be
invoked as workers; conversely, top-level launchers may want to reject #SUBAGENT
declarations as entry points (current core does not own that check — top-level launch goes
through HarnessAgent.builder() directly, not through a declaration).
Builder
public static final class Builder构建器,用于构建并配置目标实例。位于 io.agentscope.harness.agent.subagent 包。核心成员包括 name、description、workspaceMode、workspace、inlineAgentsBody、model。
A class in io.agentscope.harness.agent.subagent that supports discovery, delegation and collaboration between agents. Declared in io.agentscope.harness.agent.subagent.