AgentConfig
public class AgentConfig
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
RuntimeAgentConfigsubclass -
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
builder | Builder | 构建器(类型 `Builder`)。The builder. |
io/agentscope/extensions/scheduler/config/AgentConfig.java:92–97方法详情Method Detail
builder
public static Builder builder()
创建新的构建器实例。
Create a new builder instance.
Builderio/agentscope/extensions/scheduler/config/AgentConfig.java:116–118getName
public String getName()
获取智能体名称。
Get the agent name.
Stringio/agentscope/extensions/scheduler/config/AgentConfig.java:129–131getModelConfig
public ModelConfig getModelConfig()
获取模型配置。
Get the model configuration.
ModelConfigio/agentscope/extensions/scheduler/config/AgentConfig.java:138–140getSysPrompt
public String getSysPrompt()
获取系统提示词。
Get the system prompt.
Stringio/agentscope/extensions/scheduler/config/AgentConfig.java:147–149equals
public boolean equals(Object o)
设置该参数。
Performs the equals operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
o | Object | o(类型 `Object`)。The o. |
booleanio/agentscope/extensions/scheduler/config/AgentConfig.java:151–159hashCode
public int hashCode()
返回 hashCode 结果。
Returns the hash code.
intio/agentscope/extensions/scheduler/config/AgentConfig.java:161–164toString
public String toString()
返回 toString 结果。
Returns the to string.
Stringio/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.