AS AgentScopeAPI 手册 / API Reference

Builder

public static class Builder
源码Source io/agentscope/core/agent/RuntimeContext.java:351–450

构建器,用于构建并配置目标实例。位于 io.agentscope.core.agent 包。核心成员包括 sessionId、userId、agentState、put、putAll、from。

A class in io.agentscope.core.agent that drives agent reasoning, tool calls and conversation execution. Declared in io.agentscope.core.agent.

方法摘要Method Summary

方法Method说明Description
public Builder sessionId(String sessionId)
设置会话标识。
Performs the session id operation.
public Builder userId(String userId)
设置用户标识。
Performs the user id operation.
public Builder agentState(AgentState agentState)
设置智能体状态。
Performs the agent state operation.
public Builder put(String key, Object value)
设置该配置项。
Performs the put operation.
public Builder putAll(Map<String, Object> extras)
设置该配置项。
Performs the put all operation.
public T Builder put(Class<T> type, T value)
设置该配置项。
Performs the put operation.
public T Builder put(String key, Class<T> type, T value)
设置该配置项。
Performs the put operation.
public Builder from(RuntimeContext source)
创建并返回实例。
Creates and returns an instance.
public Builder toolExecutionContext(ToolExecutionContext toolExecutionContext)
设置工具执行上下文。
Nests a `ToolExecutionContext` (e.g.
public Builder toolRequestConfig(ToolRequestConfig toolRequestConfig)
设置工具请求配置。
Installs a per-call tool request config.
public RuntimeContext build()
构建并返回最终实例。
Creates and returns an instance.

方法详情Method Detail

sessionId

public Builder sessionId(String sessionId)

设置会话标识。

Performs the session id operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/agent/RuntimeContext.java:360–363

userId

public Builder userId(String userId)

设置用户标识。

Performs the user id operation.

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

agentState

public Builder agentState(AgentState agentState)

设置智能体状态。

Performs the agent state operation.

参数Parameters
名称Name类型Type说明Description
agentStateAgentState智能体状态(类型 `AgentState`)。The agent state.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/agent/RuntimeContext.java:370–373

put

public Builder put(String key, Object value)

设置该配置项。

Performs the put operation.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。The key.
valueObject值(类型 `Object`)。The value.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/agent/RuntimeContext.java:375–381

putAll

public Builder putAll(Map<String, Object> extras)

设置该配置项。

Performs the put all operation.

参数Parameters
名称Name类型Type说明Description
extrasMap<String, Object>extras(类型 `Map`)。The extras.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/agent/RuntimeContext.java:383–392

put

public T Builder put(Class<T> type, T value)

设置该配置项。

Performs the put operation.

参数Parameters
名称Name类型Type说明Description
typeClass<T>类型(类型 `Class`)。The type.
valueT值(类型 `T`)。The value.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/agent/RuntimeContext.java:394–396

put

public T Builder put(String key, Class<T> type, T value)

设置该配置项。

Performs the put operation.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。The key.
typeClass<T>类型(类型 `Class`)。The type.
valueT值(类型 `T`)。The value.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/agent/RuntimeContext.java:398–404

from

public Builder from(RuntimeContext source)

创建并返回实例。

Creates and returns an instance.

参数Parameters
名称Name类型Type说明Description
sourceRuntimeContext来源(类型 `RuntimeContext`)。The source.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/agent/RuntimeContext.java:406–426

toolExecutionContext

public Builder toolExecutionContext(ToolExecutionContext toolExecutionContext)

设置工具执行上下文。

Nests a ToolExecutionContext (e.g.

参数Parameters
名称Name类型Type说明Description
toolExecutionContextToolExecutionContext工具执行上下文(类型 `ToolExecutionContext`)。The tool execution context.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/agent/RuntimeContext.java:432–435

toolRequestConfig

public Builder toolRequestConfig(ToolRequestConfig toolRequestConfig)

设置工具请求配置。

Installs a per-call tool request config.

参数Parameters
名称Name类型Type说明Description
toolRequestConfigToolRequestConfig工具请求配置(类型 `ToolRequestConfig`)。The tool request config.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/agent/RuntimeContext.java:442–445

build

public RuntimeContext build()

构建并返回最终实例。

Creates and returns an instance.

返回Returns RuntimeContext
返回RuntimeContext。Returns runtime context.
源码Source io/agentscope/core/agent/RuntimeContext.java:447–449
基于官方固定版本源码静态生成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.