Interface Gateway

All Known Implementing Classes:
HarnessGateway

public interface Gateway
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(io.agentscope.harness.agent.gateway.MsgContext, java.util.List<io.agentscope.core.message.Msg>) 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 Details

    • bindMainAgent

      void bindMainAgent(HarnessAgent agent)
      Binds the primary harness agent after construction. The agent is registered under its HarnessAgent.getAgentId() for routing by run(io.agentscope.harness.agent.gateway.MsgContext, java.util.List<io.agentscope.core.message.Msg>).
    • registerAgent

      default void registerAgent(String agentId, HarnessAgent agent)
      Registers a named harness agent for routing. run(io.agentscope.harness.agent.gateway.MsgContext, java.util.List<io.agentscope.core.message.Msg>) will resolve the target agent by the agentId supplied in MsgContext.extra() (key "agentId"), falling back to the agent registered via bindMainAgent(io.agentscope.harness.agent.HarnessAgent).
    • run

      reactor.core.publisher.Mono<io.agentscope.core.message.Msg> run(MsgContext context, List<io.agentscope.core.message.Msg> messages)
      Inbound turn (direct API or channel adapter).
    • run

      default reactor.core.publisher.Mono<io.agentscope.core.message.Msg> run(MsgContext context, List<io.agentscope.core.message.Msg> messages, OutboundAddress outboundAddress)
      Inbound turn with outbound address. The outboundAddress is recorded as the session's "last route" so that proactive outbound messages (e.g. subagent announces) can be delivered back to the originating channel/peer.
      Parameters:
      context - routing context for session key resolution
      messages - the inbound messages
      outboundAddress - the delivery target for proactive replies; may be null
    • run

      default reactor.core.publisher.Mono<io.agentscope.core.message.Msg> run(MsgContext context, List<io.agentscope.core.message.Msg> messages, OutboundAddress outboundAddress, io.agentscope.core.agent.RuntimeContext callerContext)
      Inbound turn with outbound address and an optional caller RuntimeContext.

      The caller context is merged into the turn; gateway identity fields take precedence. The default implementation ignores callerContext and delegates to run(MsgContext, List).

      Parameters:
      context - routing context for session key resolution
      messages - the inbound messages
      outboundAddress - the delivery target for proactive replies; may be null
      callerContext - optional application context to merge; may be null
    • run

      default reactor.core.publisher.Mono<io.agentscope.core.message.Msg> run(MsgContext context, List<io.agentscope.core.message.Msg> messages, OutboundAddress outboundAddress, io.agentscope.core.agent.RuntimeContext callerContext, InboundMessage inboundMessage)
      Inbound turn with full Channel metadata for ChannelRuntimeContextResolver.
      Parameters:
      inboundMessage - optional inbound envelope passed to the resolver; may be null
    • run

      default reactor.core.publisher.Mono<io.agentscope.core.message.Msg> run(MsgContext context, io.agentscope.core.message.Msg message)
      Single-message convenience.
    • runStream

      default reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent> runStream(MsgContext context, List<io.agentscope.core.message.Msg> messages)
      Streaming variant of run(MsgContext, List). Returns fine-grained events.
    • runStream

      default reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent> runStream(MsgContext context, List<io.agentscope.core.message.Msg> messages, OutboundAddress outboundAddress)
    • runStream

      default reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent> runStream(MsgContext context, List<io.agentscope.core.message.Msg> messages, OutboundAddress outboundAddress, io.agentscope.core.agent.RuntimeContext callerContext)
      Streaming variant of run(MsgContext, List, OutboundAddress, RuntimeContext).

      The default signals unsupported streaming.

    • runStream

      default reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent> runStream(MsgContext context, List<io.agentscope.core.message.Msg> messages, OutboundAddress outboundAddress, io.agentscope.core.agent.RuntimeContext callerContext, InboundMessage inboundMessage)
    • runSubagent

      default reactor.core.publisher.Mono<io.agentscope.core.message.Msg> runSubagent(String subagentId, List<io.agentscope.core.message.Msg> messages)
      Routes messages directly to an exposed subagent session identified by subagentId, bypassing normal binding-based routing. Returns the subagent's reply.
      Parameters:
      subagentId - the handle returned by SubagentGatewayBridge.ExposeResult.subagentId()
      messages - the messages to send to the subagent
    • runSubagentStream

      default reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent> runSubagentStream(String subagentId, List<io.agentscope.core.message.Msg> messages)
      Streaming variant of runSubagent(String, List).