Class AgentConfig
java.lang.Object
io.agentscope.extensions.scheduler.config.AgentConfig
- Direct Known Subclasses:
RuntimeAgentConfig
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
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for creating AgentConfig instances. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AgentConfig.Builderbuilder()Create a new builder instance.booleanGet the model configuration.getName()Get the agent name.Get the system prompt.inthashCode()toString()
-
Constructor Details
-
AgentConfig
-
-
Method Details
-
builder
Create a new builder instance.- Returns:
- A new AgentConfig.Builder
-
getName
Get the agent name.This name is used as the identifier for the scheduled agent and should be unique within the scheduler. It's also used as the JobHandler name in some scheduler implementations like XXL-Job.
- Returns:
- The agent name
-
getModelConfig
Get the model configuration.- Returns:
- The ModelConfig instance
-
getSysPrompt
Get the system prompt.- Returns:
- The system prompt, may be null
-
equals
-
hashCode
public int hashCode() -
toString
-