AS AgentScopeAPI 手册 / API Reference

AgentConfig

public class AgentConfig
源码Source io/agentscope/extensions/scheduler/config/AgentConfig.java:86–254

智能体配置,保存相关配置项。位于 io.agentscope.extensions.scheduler.config 包。核心成员包括 builder、getName、getModelConfig、getSysPrompt、equals、hashCode。

Serializable metadata configuration for Agent instances in scheduled tasks.

This class contains only serializable configuration metadata, making it suitable for persistence, transmission, and distributed scheduling scenarios. It excludes runtime objects like Toolkit and Hooks.

Key Benefits:

  • Serializable - All fields are serializable configuration objects

  • Persistent - Can be stored in databases or configuration files

  • Transmittable - Can be sent across network in distributed systems

  • Type-Safe - Compile-time validation of required components

Usage Example (Basic):

`// Create model configuration
ModelConfig modelConfig = DashScopeModelConfig.builder()
.apiKey(apiKey)
.modelName("qwen-max")
.stream(true)
.build();

// Create serializable agent configuration
AgentConfig config = AgentConfig.builder()
.name("ScheduledAssistant")
.modelConfig(modelConfig)
.sysPrompt("You are a scheduled assistant.")
.build();

// Schedule with the configuration
ScheduleAgentTask task = scheduler.schedule(config, scheduleConfig);
`

Usage Example (With Runtime Objects):

`// For runtime objects like Toolkit and Hooks, use RuntimeAgentConfig
RuntimeAgentConfig runtimeConfig = RuntimeAgentConfig.builder()
.name("ScheduledAssistant")
.modelConfig(modelConfig)
.sysPrompt("You are a scheduled assistant.")
.toolkit(myToolkit) // Runtime object
.hooks(Arrays.asList(hook1)) // Runtime object
.build();

// Schedule with runtime configuration
ScheduleAgentTask task = scheduler.schedule(runtimeConfig, scheduleConfig);
`

Design Notes:

  • This class contains only serializable fields (name, modelConfig, sysPrompt)

  • For runtime objects (toolkit, hooks), use RuntimeAgentConfig subclass

  • Name and modelConfig are required fields

  • System prompt is optional

  • Immutable after construction using the builder pattern

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Builder类class
构建器,用于构建并配置目标实例。
Builder for creating AgentConfig instances.

构造器摘要Constructor Summary

构造器Constructor说明Description
protected AgentConfig(Builder builder)
初始化 `AgentConfig` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public static Builder builder()
static
创建新的构建器实例。
Create a new builder instance.
public String getName()
获取智能体名称。
Get the agent name.
public ModelConfig getModelConfig()
获取模型配置。
Get the model configuration.
public String getSysPrompt()
获取系统提示词。
Get the system prompt.
public boolean equals(Object o)
设置该参数。
Performs the equals operation.
public int hashCode()
返回 `hashCode` 结果。
Returns the hash code.
public String toString()
返回 `toString` 结果。
Returns the to string.

构造器详情Constructor Detail

AgentConfig

protected AgentConfig(Builder builder)

初始化 AgentConfig 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
builderBuilder构建器(类型 `Builder`)。The builder.
源码Source io/agentscope/extensions/scheduler/config/AgentConfig.java:92–97

方法详情Method Detail

builder

public static Builder builder()
static

创建新的构建器实例。

Create a new builder instance.

返回Returns Builder
一种新的AgentConfig.构建器。A new AgentConfig.Builder
源码Source io/agentscope/extensions/scheduler/config/AgentConfig.java:116–118

getName

public String getName()

获取智能体名称。

Get the agent name.

返回Returns String
智能体名称。The agent name
源码Source io/agentscope/extensions/scheduler/config/AgentConfig.java:129–131

getModelConfig

public ModelConfig getModelConfig()

获取模型配置。

Get the model configuration.

返回Returns ModelConfig
ModelConfig 实例。The ModelConfig instance
源码Source io/agentscope/extensions/scheduler/config/AgentConfig.java:138–140

getSysPrompt

public String getSysPrompt()

获取系统提示词。

Get the system prompt.

返回Returns String
返回字符串结果。The system prompt, may be null
源码Source io/agentscope/extensions/scheduler/config/AgentConfig.java:147–149

equals

public boolean equals(Object o)

设置该参数。

Performs the equals operation.

参数Parameters
名称Name类型Type说明Description
oObjecto(类型 `Object`)。The o.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/scheduler/config/AgentConfig.java:151–159

hashCode

public int hashCode()

返回 hashCode 结果。

Returns the hash code.

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/extensions/scheduler/config/AgentConfig.java:161–164

toString

public String toString()

返回 toString 结果。

Returns the to string.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/scheduler/config/AgentConfig.java:166–178

嵌套类详情Nested Class Detail

Builder

public static class Builder

构建器,用于构建并配置目标实例。位于 io.agentscope.extensions.scheduler.config 包。核心成员包括 name、modelConfig、sysPrompt、build、Builder。

Builder for creating AgentConfig instances.

基于官方固定版本源码静态生成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.