AS AgentScopeAPI 手册 / API Reference

DefaultAgentManager

public final class DefaultAgentManager
源码Source io/agentscope/harness/agent/subagent/DefaultAgentManager.java:46–260

默认智能体管理器,支持智能体之间的发现、委派与协作。位于 io.agentscope.harness.agent.subagent 包。核心成员包括 refreshEntries、replaceAgents、createAgentIfPresent、isPrimaryOnly、hasAgent、getAgentFactories。

Pure agent factory and invoker — knows how to create agents from registered factories and invoke them with a prompt.

This is the agent-internal layer. It has no session registry, no lane management, no run tracking. The agent-internal AgentSpawnTool uses this directly for lightweight subagent invocation.

构造器摘要Constructor Summary

构造器Constructor说明Description
public DefaultAgentManager(List<SubagentEntry> entries, WorkspaceManager workspaceManager)
初始化 `DefaultAgentManager` 实例。
Builds a manager from subagent entries (factories plus optional `SubagentDeclaration` metadata for remote configuration).

方法摘要Method Summary

方法Method说明Description
public void refreshEntries(List<SubagentEntry> entries)
设置刷新条目。
Replaces the current set of entries with a new snapshot.
public void replaceAgents(List<SubagentEntry> entries)
设置该参数。
Atomic alias of `#refreshEntries(List)` used by `io.agentscope.harness.agent.middleware.DynamicSubagentsMiddleware` to swap the registered subagent set on every reasoning step.
public Optional<Agent> createAgentIfPresent(String agentId, RuntimeContext parentRc)
创建 `createAgentIfPresent`。
Race-safe lookup-and-create.
public boolean isPrimaryOnly(String agentId)
判断是否 `isPrimaryOnly`。
Returns `true` when `agentId` is registered with a `PRIMARY`-only declaration.
public boolean hasAgent(String agentId)
判断是否具有智能体。
Whether a factory is registered for the given agent id.
public Map<String, SubagentFactory> getAgentFactories()
获取 `getAgentFactories`。
Immutable view of registered subagent factories keyed by `agent_id`.
public Optional<SubagentDeclaration> getDeclaration(String agentId)
获取 `getDeclaration`。
Optional declaration metadata for the given `agent_id` (e.g.
public Agent createAgent(String agentId, RuntimeContext parentRc)
创建新的智能体实例来自已注册工厂。
Creates a new agent instance from the registered factory.
public Mono<Msg> invokeAgent(Agent agent, String sessionId, String userId, String prompt)
调用智能体。
Invokes an agent with a user prompt.
public Mono<Msg> invokeAgent(Agent agent, String sessionId, String userId, String prompt, RuntimeContext parentRc)
调用智能体。
Invokes the agent.
public Flux<Event> invokeAgentStream(Agent agent, String sessionId, String userId, String prompt, EventSource source, StreamOptions options)
调用智能体流。
Invokes an agent and returns its execution as a tagged `Flux` of `Event`s.
public Flux<Event> invokeAgentStream(Agent agent, String sessionId, String userId, String prompt, EventSource source, StreamOptions options, RuntimeContext parentRc)
调用智能体流。
Invokes the agent stream.
public WorkspaceManager getWorkspaceManager()
获取工作区管理器。
Returns the workspace manager.

构造器详情Constructor Detail

DefaultAgentManager

public DefaultAgentManager(List<SubagentEntry> entries, WorkspaceManager workspaceManager)

初始化 DefaultAgentManager 实例。

Builds a manager from subagent entries (factories plus optional SubagentDeclaration metadata for remote configuration).

参数Parameters
名称Name类型Type说明Description
entriesList<SubagentEntry>条目(类型 `List`)。The entries.
workspaceManagerWorkspaceManager工作区管理器(类型 `WorkspaceManager`)。The workspace manager.
源码Source io/agentscope/harness/agent/subagent/DefaultAgentManager.java:56–68

方法详情Method Detail

refreshEntries

public void refreshEntries(List<SubagentEntry> entries)

设置刷新条目。

Replaces the current set of entries with a new snapshot.

参数Parameters
名称Name类型Type说明Description
entriesList<SubagentEntry>条目(类型 `List`)。The entries.
源码Source io/agentscope/harness/agent/subagent/DefaultAgentManager.java:71–82

replaceAgents

public void replaceAgents(List<SubagentEntry> entries)

设置该参数。

Atomic alias of #refreshEntries(List) used by io.agentscope.harness.agent.middleware.DynamicSubagentsMiddleware to swap the registered subagent set on every reasoning step.

参数Parameters
名称Name类型Type说明Description
entriesList<SubagentEntry>条目(类型 `List`)。The entries.
源码Source io/agentscope/harness/agent/subagent/DefaultAgentManager.java:91–93

createAgentIfPresent

public Optional<Agent> createAgentIfPresent(String agentId, RuntimeContext parentRc)

创建 createAgentIfPresent。

Race-safe lookup-and-create.

参数Parameters
名称Name类型Type说明Description
agentIdString智能体标识(类型 `String`)。The agent id.
parentRcRuntimeContext父级 Rc(类型 `RuntimeContext`)。The parent rc.
返回Returns Optional<Agent>
返回可选。Returns optional.
源码Source io/agentscope/harness/agent/subagent/DefaultAgentManager.java:107–120

isPrimaryOnly

public boolean isPrimaryOnly(String agentId)

判断是否 isPrimaryOnly。

Returns true when agentId is registered with a PRIMARY-only declaration.

参数Parameters
名称Name类型Type说明Description
agentIdString智能体标识(类型 `String`)。The agent id.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/harness/agent/subagent/DefaultAgentManager.java:128–132

hasAgent

public boolean hasAgent(String agentId)

判断是否具有智能体。

Whether a factory is registered for the given agent id.

参数Parameters
名称Name类型Type说明Description
agentIdString智能体标识(类型 `String`)。The agent id.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/harness/agent/subagent/DefaultAgentManager.java:135–137

getAgentFactories

public Map<String, SubagentFactory> getAgentFactories()

获取 getAgentFactories。

Immutable view of registered subagent factories keyed by agent_id.

返回Returns Map<String, SubagentFactory>
返回映射。Returns map.
源码Source io/agentscope/harness/agent/subagent/DefaultAgentManager.java:140–142

getDeclaration

public Optional<SubagentDeclaration> getDeclaration(String agentId)

获取 getDeclaration。

Optional declaration metadata for the given agent_id (e.g.

参数Parameters
名称Name类型Type说明Description
agentIdString智能体标识(类型 `String`)。The agent id.
返回Returns Optional<SubagentDeclaration>
返回可选。Returns optional.
源码Source io/agentscope/harness/agent/subagent/DefaultAgentManager.java:145–147

createAgent

public Agent createAgent(String agentId, RuntimeContext parentRc)

创建新的智能体实例来自已注册工厂。

Creates a new agent instance from the registered factory.

参数Parameters
名称Name类型Type说明Description
agentIdString智能体标识(类型 `String`)。The agent id.
parentRcRuntimeContext父级 Rc(类型 `RuntimeContext`)。The parent rc.
返回Returns Agent
返回智能体。Returns agent.
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if no factory is registered for the given id
源码Source io/agentscope/harness/agent/subagent/DefaultAgentManager.java:154–160

invokeAgent

public Mono<Msg> invokeAgent(Agent agent, String sessionId, String userId, String prompt)

调用智能体。

Invokes an agent with a user prompt.

参数Parameters
名称Name类型Type说明Description
agentAgent智能体到调用。the agent to invoke
sessionIdString会话标识(类型 `String`)。a new, child-specific session id
userIdString用户标识(类型 `String`)。the parent's user-id (may be `null`)
promptString用户消息到发送。the user message to send
返回Returns Mono<Msg>
返回Mono。Returns mono.
源码Source io/agentscope/harness/agent/subagent/DefaultAgentManager.java:175–177

invokeAgent

public Mono<Msg> invokeAgent(Agent agent, String sessionId, String userId, String prompt, RuntimeContext parentRc)

调用智能体。

Invokes the agent.

参数Parameters
名称Name类型Type说明Description
agentAgent智能体(类型 `Agent`)。The agent.
sessionIdString会话标识(类型 `String`)。The session id.
userIdString用户标识(类型 `String`)。The user id.
promptString提示词(类型 `String`)。The prompt.
parentRcRuntimeContext父级 Rc(类型 `RuntimeContext`)。The parent rc.
返回Returns Mono<Msg>
返回Mono。Returns mono.
源码Source io/agentscope/harness/agent/subagent/DefaultAgentManager.java:179–195

invokeAgentStream

public Flux<Event> invokeAgentStream(Agent agent, String sessionId, String userId, String prompt, EventSource source, StreamOptions options)

调用智能体流。

Invokes an agent and returns its execution as a tagged Flux of Events.

参数Parameters
名称Name类型Type说明Description
agentAgent智能体到调用。the agent to invoke
sessionIdString会话标识(类型 `String`)。a new, child-specific session id
userIdString用户标识(类型 `String`)。the parent's user-id (may be `null`)
promptString用户消息到发送。the user message to send
sourceEventSource来源(类型 `EventSource`)。the `EventSource` that will be stamped onto every emitted event
optionsStreamOptions选项(类型 `StreamOptions`)。stream configuration passed to the child agent
返回Returns Flux<Event>
返回Flux。`Flux` of tagged events; never null
源码Source io/agentscope/harness/agent/subagent/DefaultAgentManager.java:216–224

invokeAgentStream

public Flux<Event> invokeAgentStream(Agent agent, String sessionId, String userId, String prompt, EventSource source, StreamOptions options, RuntimeContext parentRc)

调用智能体流。

Invokes the agent stream.

参数Parameters
名称Name类型Type说明Description
agentAgent智能体(类型 `Agent`)。The agent.
sessionIdString会话标识(类型 `String`)。The session id.
userIdString用户标识(类型 `String`)。The user id.
promptString提示词(类型 `String`)。The prompt.
sourceEventSource来源(类型 `EventSource`)。The source.
optionsStreamOptions选项(类型 `StreamOptions`)。The options.
parentRcRuntimeContext父级 Rc(类型 `RuntimeContext`)。The parent rc.
返回Returns Flux<Event>
返回Flux。Returns flux.
源码Source io/agentscope/harness/agent/subagent/DefaultAgentManager.java:226–251

getWorkspaceManager

public WorkspaceManager getWorkspaceManager()

获取工作区管理器。

Returns the workspace manager.

返回Returns WorkspaceManager
返回WorkspaceManager。Returns workspace manager.
源码Source io/agentscope/harness/agent/subagent/DefaultAgentManager.java:253–255
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.