Class GatewayBootstrap
java.lang.Object
io.agentscope.harness.agent.gateway.GatewayBootstrap
Multi-agent + channel routing bootstrap. The primary user-facing entry point for building a
gateway-managed agent system.
Minimal usage — single agent + ChatUI
HarnessAgent agent = HarnessAgent.builder()
.model(model).name("assistant").sysPrompt("You are helpful.")
.build();
GatewayBootstrap gw = GatewayBootstrap.builder()
.agent("main", agent)
.build();
ChatUiChannel chat = gw.chatUiChannel();
Msg reply = chat.send("hello").block();
Multi-agent + binding routing
GatewayBootstrap gw = GatewayBootstrap.builder()
.agent("sales", salesAgent)
.agent("support", supportAgent)
.mainAgent("sales")
.build();
ChannelConfig config = ChannelConfig.builder("chatui")
.dmScope(DmScope.PER_PEER)
.binding(ChannelBinding.forPeer("direct:vip-user-1", "support"))
.build();
ChatUiChannel chat = gw.chatUiChannel(config);
chat.send("vip-user-1", "help me").block(); // routes to support agent
chat.send("normal-user", "hi").block(); // routes to sales (default)
External channels
GatewayBootstrap gw = GatewayBootstrap.builder()
.agent("main", agent)
.channel(mySlackChannel)
.build();
gw.start(); // init + start all channels
gw.stop(); // stop all channels
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionagents()The registered agents keyed by id.static GatewayBootstrap.Builderbuilder()Returns a new builder.The channel manager (advanced usage).Returns aChatUiChannelwith default DmScope.MAIN config, pre-wired to this gateway.chatUiChannel(ChannelConfig config) Returns aChatUiChannelwith custom routing config, pre-wired to this gateway.gateway()The underlying gateway (advanced usage).Returns aSubagentGatewayBridgethat exposes subagents as user-addressable threads within this gateway.The main agent id.start()Initializes and starts all pre-registered channels (injecting the gateway into each).voidstop()Stops all channels and releases resources.
-
Method Details
-
builder
Returns a new builder. -
gateway
The underlying gateway (advanced usage). -
channelManager
The channel manager (advanced usage). -
agents
The registered agents keyed by id. -
mainAgentId
The main agent id. -
gatewayBridge
Returns aSubagentGatewayBridgethat exposes subagents as user-addressable threads within this gateway. Pass this toSubagentsMiddleware.setGatewayBridge(io.agentscope.harness.agent.gateway.SubagentGatewayBridge)to enable theexpose_to_userparameter onagent_spawn. -
chatUiChannel
Returns aChatUiChannelwith default DmScope.MAIN config, pre-wired to this gateway. All conversations share a single session. -
chatUiChannel
Returns aChatUiChannelwith custom routing config, pre-wired to this gateway. Use to configure DmScope, bindings, or default agent overrides. -
start
Initializes and starts all pre-registered channels (injecting the gateway into each). Call this after build() when using external channels (Slack, Telegram, etc.). -
stop
public void stop()Stops all channels and releases resources.
-