Skip to main content
Kapso can continue a previous evolution campaign from its exact search and orchestration state. Resume is intentionally strict: it never converts a missing, corrupt, incompatible, or completed checkpoint into a new campaign.

Basic usage

Run one iteration and keep the workspace:
Continue it with one additional iteration:
max_iterations is the number of iterations attempted by the current call. It is not a new lifetime limit. The result distinguishes the two counts:
The same operation is available from the CLI:

Resume flow

Validation happens before Kapso initializes or changes the experiment workspace. A failed resume request therefore does not create a Git repository, rename a branch, or overwrite campaign state.

Strict requirements

With resume=True:
  • output_path is required and must already be a directory.
  • The path must be a non-bare Git repository.
  • .kapso/run_state.json must exist, unless trusted legacy migration is explicitly enabled.
  • The checkpoint schema must be supported and structurally valid.
  • The goal must match exactly.
  • The configured search strategy and configuration fingerprint must match.
  • A campaign marked completed cannot be resumed.
Starting without resume=True in a workspace that already has a run checkpoint also fails. This prevents accidental replacement of a campaign.

Checkpoint contents

Kapso owns the checkpoint rather than delegating persistence to each strategy. The current schema is:
The configuration fingerprint includes the selected mode configuration, strategy type and parameters, any coding-agent override, and the external evaluator identity and failure policy when one is configured. It prevents a run from silently continuing under different search, model, or measurement settings. When eval_dir is provided, its content fingerprint is also part of strict compatibility. Pass the same unchanged suite to every resumed call.

Atomic saves and iteration boundaries

The checkpoint is written to a temporary file in .kapso/, flushed, and then installed with os.replace. If replacement is interrupted, the previous valid checkpoint remains readable. Kapso saves after every finalized iteration, including the iteration that achieves the goal. It records only nodes returned as completed by the strategy; a half-created iteration is not added to completed_iterations. Status has two values:
  • running: the call reached its iteration slice and can be resumed.
  • completed: the goal was achieved or a time/cost budget ended the campaign.
The checkpoint file and temporary files are ignored by the experiment Git repository. Candidate branches remain normal Git artifacts, while orchestration state remains local runtime state.

What is restored

Resume restores:
  • generic-search node history and next iteration number;
  • tree-search nodes, parent/child references, event history, and experiment count;
  • feedback injected into the next iteration;
  • cumulative campaign cost;
  • cumulative completed-iteration count;
  • the status needed to reject completed campaigns.
Experiment history already stored in .kapso/experiment_history.json is loaded by the normal history store.

Failure handling

Resume errors are available from the top-level kapso package:
Fix the mismatch or choose the correct workspace. Do not delete validation fields to force a resume; use a new output path for a new campaign.

Trusted legacy migration

Older Kapso versions wrote checkpoint.pkl. Pickle can execute code while loading, so migration is opt-in and must only be used for a workspace you trust:
Kapso imports the built-in strategy’s legacy state, immediately writes the versioned JSON checkpoint, and renames the pickle to checkpoint.pkl.migrated. Later resumes use JSON and do not deserialize the pickle again. Legacy checkpoints do not contain goal/configuration metadata, so the explicit trust decision also accepts the goal and configuration supplied to the migration call.

Custom search strategies

A resumable custom strategy implements JSON-compatible state methods:
State must contain only JSON-compatible values. Object graphs with references, such as tree search, should store IDs and rebuild references during load_state().