AS AgentScopeAPI 手册 / API Reference

Builder

public static final class Builder
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:176–330

构建器,用于构建并配置目标实例。位于 io.agentscope.harness.agent.gateway 包。核心成员包括 agent、mainAgent、channel、configureAllAgents、distributedStore、runtimeContextResolver。

A class in io.agentscope.harness.agent.gateway that deploys, schedules and serves agents. Declared in io.agentscope.harness.agent.gateway.

方法摘要Method Summary

方法Method说明Description
public Builder agent(String id, HarnessAgent agent)
设置智能体。
Registers a pre-built agent under the given id.
public Builder agent(String id, Consumer<HarnessAgent.Builder> configurator)
设置智能体。
Registers an agent declared via a builder lambda.
public Builder mainAgent(String id)
设置主智能体。
Sets the main agent id (used as the routing fallback).
public Builder channel(Channel... channels)
设置渠道。
Registers one or more external channels for gateway management.
public Builder configureAllAgents(Consumer<HarnessAgent.Builder> customizer)
设置该配置项。
Applies a customizer to every agent builder created via the lambda-based `#agent(String, Consumer)` method.
public Builder distributedStore(DistributedStore store)
设置分布式存储。
Sets the distributed store used to build a durable `SubagentRegistry`, making subagents exposed via `expose_to_user` resolvable and re-materializable across nodes / restarts.
public Builder runtimeContextResolver(ChannelRuntimeContextResolver resolver)
设置运行时上下文解析器。
Sets a `ChannelRuntimeContextResolver` that supplies / replaces caller ` RuntimeContext` on each Gateway turn before identity fields are applied.
public GatewayBootstrap build()
构建并返回最终实例。
Builds the gateway bootstrap.

方法详情Method Detail

agent

public Builder agent(String id, HarnessAgent agent)

设置智能体。

Registers a pre-built agent under the given id.

参数Parameters
名称Name类型Type说明Description
idString标识(类型 `String`)。The id.
agentHarnessAgent智能体(类型 `HarnessAgent`)。The agent.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:188–193

agent

public Builder agent(String id, Consumer<HarnessAgent.Builder> configurator)

设置智能体。

Registers an agent declared via a builder lambda.

参数Parameters
名称Name类型Type说明Description
idString标识(类型 `String`)。The id.
configuratorConsumer<HarnessAgent.Builder>configurator(类型 `Consumer`)。The configurator.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:199–209

mainAgent

public Builder mainAgent(String id)

设置主智能体。

Sets the main agent id (used as the routing fallback).

参数Parameters
名称Name类型Type说明Description
idString标识(类型 `String`)。The id.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:215–218

channel

public Builder channel(Channel... channels)

设置渠道。

Registers one or more external channels for gateway management.

参数Parameters
名称Name类型Type说明Description
channels varargsChannel...渠道(类型 `Channel...`)。The channels.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:221–226

configureAllAgents

public Builder configureAllAgents(Consumer<HarnessAgent.Builder> customizer)

设置该配置项。

Applies a customizer to every agent builder created via the lambda-based #agent(String, Consumer) method.

参数Parameters
名称Name类型Type说明Description
customizerConsumer<HarnessAgent.Builder>customizer(类型 `Consumer`)。The customizer.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:232–235

distributedStore

public Builder distributedStore(DistributedStore store)

设置分布式存储。

Sets the distributed store used to build a durable SubagentRegistry, making subagents exposed via expose_to_user resolvable and re-materializable across nodes / restarts.

参数Parameters
名称Name类型Type说明Description
storeDistributedStore存储实例(类型 `DistributedStore`)。The store.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:244–247

runtimeContextResolver

public Builder runtimeContextResolver(ChannelRuntimeContextResolver resolver)

设置运行时上下文解析器。

Sets a ChannelRuntimeContextResolver that supplies / replaces caller RuntimeContext on each Gateway turn before identity fields are applied.

参数Parameters
名称Name类型Type说明Description
resolverChannelRuntimeContextResolver解析器(类型 `ChannelRuntimeContextResolver`)。The resolver.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:254–257

build

public GatewayBootstrap build()

构建并返回最终实例。

Builds the gateway bootstrap.

返回Returns GatewayBootstrap
返回GatewayBootstrap。Returns gateway bootstrap.
抛出Throws
  • IllegalStateException 可能抛出 `IllegalStateException`。if no agents are registered
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:264–329
基于官方固定版本源码静态生成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.