Annotation Interface PersistenceConfig


@Target(TYPE) @Retention(RUNTIME) public @interface PersistenceConfig
Configures the persistence behavior for an agent class.

Place this annotation on any class that extends BaseAgent to control when the runtime saves the fields marked with Persist and how snapshots are managed.

Example — periodic auto-save every 30 seconds


 @Agent("order-processor")
 @PersistenceConfig(
     strategy = PersistenceStrategy.PERIODIC,
     interval  = "30s"
 )
 public class OrderProcessorAgent extends BaseAgent {

     @Persist(required = true)
     private String currentOrderId;

     @Persist
     private int retryCount = 0;
 }
 

Example — save on stop and hourly snapshots, keep last 24


 @PersistenceConfig(
     strategy         = PersistenceStrategy.ON_STOP,
     autoSnapshot     = true,
     snapshotInterval = "1h",
     maxSnapshots     = 24
 )
 public class CriticalAgent extends BaseAgent { ... }
 

When this annotation is absent the agent uses PersistenceStrategy.MANUAL (no automatic persistence; the agent must call persistState() explicitly).

Since:
0.2.0
See Also:
  • Element Details

    • strategy

      Determines when the runtime automatically saves agent state. Defaults to PersistenceStrategy.MANUAL — the agent is responsible for calling persistState() at the appropriate time.
      Default:
      MANUAL
    • interval

      String interval
      Save interval used by PersistenceStrategy.PERIODIC and PersistenceStrategy.DEBOUNCED. Accepts human-readable durations such as "30s", "5m", "1h". Ignored for other strategies.
      Default:
      "60s"
    • autoSnapshot

      boolean autoSnapshot
      When true, the runtime creates point-in-time snapshots on the schedule defined by snapshotInterval(). Snapshots allow rolling back to a previous state independently of the normal save cycle.
      Default:
      false
    • snapshotInterval

      String snapshotInterval
      How often an automatic snapshot is taken. Accepts human-readable durations such as "1h", "1d". Only relevant when autoSnapshot() is true.
      Default:
      "1h"
    • maxSnapshots

      int maxSnapshots
      Maximum number of automatic snapshots to retain. Older snapshots are deleted once this limit is exceeded (FIFO eviction).
      Default:
      10