Basic usage
Run one iteration and keep the workspace: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:
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
Withresume=True:
output_pathis required and must already be a directory.- The path must be a non-bare Git repository.
.kapso/run_state.jsonmust 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
completedcannot be resumed.
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: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.
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.
.kapso/experiment_history.json is loaded
by the normal history store.
Failure handling
Resume errors are available from the top-levelkapso 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 wrotecheckpoint.pkl. Pickle can execute code while
loading, so migration is opt-in and must only be used for a workspace you
trust:
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:load_state().