Class AgentConfig

java.lang.Object
io.agentscope.extensions.scheduler.config.AgentConfig
Direct Known Subclasses:
RuntimeAgentConfig

public class AgentConfig extends Object
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
See Also:
  • Constructor Details

  • Method Details

    • builder

      public static AgentConfig.Builder builder()
      Create a new builder instance.
      Returns:
      A new AgentConfig.Builder
    • getName

      public String 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

      public ModelConfig getModelConfig()
      Get the model configuration.
      Returns:
      The ModelConfig instance
    • getSysPrompt

      public String getSysPrompt()
      Get the system prompt.
      Returns:
      The system prompt, may be null
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object