HarnessGateway
public final class HarnessGateway implements Gateway
io/agentscope/harness/coding/gateway/HarnessGateway.java:70–462Harness 网关,承载智能体的部署、调度与服务化运行。位于 io.agentscope.harness.coding.gateway 包,实现 Gateway。核心成员包括 create、sessionAgentManager、channelManager、bindMainAgent、registerAgent、run。
Gateway-style gateway: routes inbound turns by MsgContext, and dispatches subagent
completion announces as new HarnessAgent runs on the root requester (OpenClaw gateway
analogue).
AgentStateStore management is delegated to SessionAgentManager. The gateway wires itself as
the SessionAgentManager.AnnounceDispatcher and SessionAgentManager.SpawnInterceptor on creation, so subagent spawns and announces flow through
the correct channel gates.
AgentStateStore routing
On the first #run call for a given MsgContext#canonicalKey(), a MAIN session is
registered in the SessionAgentManager. Subsequent calls for the same key reuse that
session. Multiple harness agents may be registered with #registerAgent for agentId-based
routing.
Per-session turn serialization
Each MsgContext#canonicalKey() has a fair lock (SessionTurnGate) so at most one
HarnessAgent.call runs at a time for that key.
方法摘要Method Summary
方法详情Method Detail
create
public static HarnessGateway create(SessionAgentManager sessionAgentManager, ChannelManager channelManager)
创建并返回实例。
Creates a gateway wired to the given SessionAgentManager and ChannelManager.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionAgentManager | SessionAgentManager | 会话智能体管理器(类型 `SessionAgentManager`)。session and agent lifecycle manager |
channelManager | ChannelManager | 渠道管理器(类型 `ChannelManager`)。channel registry for outbound delivery; may be null if outbound delivery is not needed |
HarnessGatewayio/agentscope/harness/coding/gateway/HarnessGateway.java:128–136create
public static HarnessGateway create(SessionAgentManager sessionAgentManager)
创建并返回实例。
Creates a gateway without a channel manager (no outbound delivery support).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionAgentManager | SessionAgentManager | 会话智能体管理器(类型 `SessionAgentManager`)。The session agent manager. |
HarnessGatewayio/agentscope/harness/coding/gateway/HarnessGateway.java:139–141sessionAgentManager
public SessionAgentManager sessionAgentManager()
返回会话智能体管理器。
The session agent manager used by this gateway.
SessionAgentManagerio/agentscope/harness/coding/gateway/HarnessGateway.java:144–146channelManager
public ChannelManager channelManager()
返回渠道管理器。
The channel manager for outbound delivery, or null if not configured.
ChannelManagerio/agentscope/harness/coding/gateway/HarnessGateway.java:149–151bindMainAgent
public void bindMainAgent(HarnessAgent agent)
设置该参数。
Binds the primary harness agent.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agent | HarnessAgent | 智能体(类型 `HarnessAgent`)。The agent. |
io/agentscope/harness/coding/gateway/HarnessGateway.java:195–202registerAgent
public void registerAgent(String agentId, HarnessAgent agent)
注册智能体。
Registers the agent.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agentId | String | 智能体标识(类型 `String`)。The agent id. |
agent | HarnessAgent | 智能体(类型 `HarnessAgent`)。The agent. |
io/agentscope/harness/coding/gateway/HarnessGateway.java:204–209run
public Mono<Msg> run(MsgContext context, List<Msg> messages)
执行运行相关操作。
Direct or channel-originated turn.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
context | MsgContext | 上下文(类型 `MsgContext`)。The context. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
Mono<Msg>io/agentscope/harness/coding/gateway/HarnessGateway.java:216–219run
public Mono<Msg> run(MsgContext context, List<Msg> messages, OutboundAddress outboundAddress)
执行运行相关操作。
Inbound turn with outbound address tracking.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
context | MsgContext | 上下文(类型 `MsgContext`)。The context. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
outboundAddress | OutboundAddress | 出站 Address(类型 `OutboundAddress`)。The outbound address. |
Mono<Msg>io/agentscope/harness/coding/gateway/HarnessGateway.java:226–260