Gateway
public interface Gateway
io/agentscope/harness/agent/gateway/Gateway.java:39–163定义网关契约的接口。位于 io.agentscope.harness.agent.gateway 包。核心成员包括 bindMainAgent、registerAgent、run、runStream、runSubagent、runSubagentStream。
Gateway-style entrypoint: route inbound turns by MsgContext, and bind the primary HarnessAgent for announce delivery.
Implementations should serialize turns per logical session (fair wait) so injected announce
runs and user/channel #run calls do not race the same HarnessAgent turn.
Callers may supply a RuntimeContext that is merged into the agent turn. Gateway-owned
identity fields (sessionId, userId, outboundAddress, …) always win on
conflict.
方法摘要Method Summary
方法详情Method Detail
bindMainAgent
public void bindMainAgent(HarnessAgent agent)
设置该参数。
Binds the primary harness agent after construction.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agent | HarnessAgent | 智能体(类型 `HarnessAgent`)。The agent. |
io/agentscope/harness/agent/gateway/Gateway.java:45registerAgent
default public void registerAgent(String agentId, HarnessAgent agent)
注册智能体。
Registers a named harness agent for routing.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agentId | String | 智能体标识(类型 `String`)。The agent id. |
agent | HarnessAgent | 智能体(类型 `HarnessAgent`)。The agent. |
io/agentscope/harness/agent/gateway/Gateway.java:52run
public Mono<Msg> run(MsgContext context, List<Msg> messages)
执行运行相关操作。
Inbound turn (direct API or channel adapter).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
context | MsgContext | 上下文(类型 `MsgContext`)。The context. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
Mono<Msg>io/agentscope/harness/agent/gateway/Gateway.java:55run
default public Mono<Msg> run(MsgContext context, List<Msg> messages, OutboundAddress outboundAddress)
执行运行相关操作。
Inbound turn with outbound address.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
context | MsgContext | 上下文(类型 `MsgContext`)。routing context for session key resolution |
messages | List<Msg> | 入站消息。the inbound messages |
outboundAddress | OutboundAddress | 出站 Address(类型 `OutboundAddress`)。the delivery target for proactive replies; may be null |
Mono<Msg>io/agentscope/harness/agent/gateway/Gateway.java:66–68run
default public Mono<Msg> run(MsgContext context, List<Msg> messages, OutboundAddress outboundAddress, RuntimeContext callerContext)
执行运行相关操作。
Inbound turn with outbound address and an optional caller RuntimeContext.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
context | MsgContext | 上下文(类型 `MsgContext`)。routing context for session key resolution |
messages | List<Msg> | 入站消息。the inbound messages |
outboundAddress | OutboundAddress | 出站 Address(类型 `OutboundAddress`)。the delivery target for proactive replies; may be null |
callerContext | RuntimeContext | caller 上下文(类型 `RuntimeContext`)。optional application context to merge; may be null |
Mono<Msg>io/agentscope/harness/agent/gateway/Gateway.java:82–88run
default public Mono<Msg> run(MsgContext context, List<Msg> messages, OutboundAddress outboundAddress, RuntimeContext callerContext, InboundMessage inboundMessage)
执行运行相关操作。
Inbound turn with full Channel metadata for io.agentscope.harness.agent.gateway.channel.ChannelRuntimeContextResolver.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
context | MsgContext | 上下文(类型 `MsgContext`)。The context. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
outboundAddress | OutboundAddress | 出站 Address(类型 `OutboundAddress`)。The outbound address. |
callerContext | RuntimeContext | caller 上下文(类型 `RuntimeContext`)。The caller context. |
inboundMessage | InboundMessage | 入站消息(类型 `InboundMessage`)。optional inbound envelope passed to the resolver; may be null |
Mono<Msg>io/agentscope/harness/agent/gateway/Gateway.java:96–103run
default public Mono<Msg> run(MsgContext context, Msg message)
执行运行相关操作。
Single-message convenience.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
context | MsgContext | 上下文(类型 `MsgContext`)。The context. |
message | Msg | 消息(类型 `Msg`)。The message. |
Mono<Msg>io/agentscope/harness/agent/gateway/Gateway.java:106–108runStream
default public Flux<AgentEvent> runStream(MsgContext context, List<Msg> messages)
运行流。
Streaming variant of #run(MsgContext, List).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
context | MsgContext | 上下文(类型 `MsgContext`)。The context. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/Gateway.java:111–113runStream
default public Flux<AgentEvent> runStream(MsgContext context, List<Msg> messages, OutboundAddress outboundAddress)
运行流。
Streaming variant of #run(MsgContext, List, OutboundAddress).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
context | MsgContext | 上下文(类型 `MsgContext`)。The context. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
outboundAddress | OutboundAddress | 出站 Address(类型 `OutboundAddress`)。The outbound address. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/Gateway.java:116–119runStream
default public Flux<AgentEvent> runStream(MsgContext context, List<Msg> messages, OutboundAddress outboundAddress, RuntimeContext callerContext)
运行流。
Streaming variant of #run(MsgContext, List, OutboundAddress, RuntimeContext).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
context | MsgContext | 上下文(类型 `MsgContext`)。The context. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
outboundAddress | OutboundAddress | 出站 Address(类型 `OutboundAddress`)。The outbound address. |
callerContext | RuntimeContext | caller 上下文(类型 `RuntimeContext`)。The caller context. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/Gateway.java:126–132runStream
default public Flux<AgentEvent> runStream(MsgContext context, List<Msg> messages, OutboundAddress outboundAddress, RuntimeContext callerContext, InboundMessage inboundMessage)
运行流。
Streaming variant of #run(MsgContext, List, OutboundAddress, RuntimeContext, InboundMessage).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
context | MsgContext | 上下文(类型 `MsgContext`)。The context. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
outboundAddress | OutboundAddress | 出站 Address(类型 `OutboundAddress`)。The outbound address. |
callerContext | RuntimeContext | caller 上下文(类型 `RuntimeContext`)。The caller context. |
inboundMessage | InboundMessage | 入站消息(类型 `InboundMessage`)。The inbound message. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/Gateway.java:138–145runSubagent
default public Mono<Msg> runSubagent(String subagentId, List<Msg> messages)
运行子智能体。
Routes messages directly to an exposed subagent session identified by subagentId, bypassing normal binding-based routing.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
subagentId | String | 子智能体标识(类型 `String`)。the handle returned by `SubagentGatewayBridge.ExposeResult#subagentId()` |
messages | List<Msg> | 消息到发送到子智能体。the messages to send to the subagent |
Mono<Msg>io/agentscope/harness/agent/gateway/Gateway.java:155–157runSubagentStream
default public Flux<AgentEvent> runSubagentStream(String subagentId, List<Msg> messages)
运行子智能体流。
Streaming variant of #runSubagent(String, List).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
subagentId | String | 子智能体标识(类型 `String`)。The subagent id. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/Gateway.java:160–162