Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(runtime): run legacy migrations before build completes

Steven Enamakel89d7edf5ea39
diff --git a/crates/openhuman-core/src/core/runtime/builder.rs b/crates/openhuman-core/src/core/runtime/builder.rs
index d96d97bdfc..dd65f9e0e1 100644
--- a/crates/openhuman-core/src/core/runtime/builder.rs
+++ b/crates/openhuman-core/src/core/runtime/builder.rs
@@ -635,6 +635,13 @@ impl CoreBuilder {
)
.await?;
+ // Legacy goal, task-board, and run-ledger rows must be copied before
+ // `build()` exposes in-process RPC or agent turns. Running these from
+ // `serve()` is too late for embedders that only build and invoke.
+ if let Some(cfg) = config.as_ref() {
+ crate::core::runtime::services::run_legacy_migrations(cfg).await;
+ }
+
// Reap agent runs orphaned by a previous process (crash / restart /
// deploy). Here, and not with the other boot-once jobs, because those
// run from `serve()`: an embedder that only calls `build()` and then
diff --git a/crates/openhuman-core/src/core/runtime/services.rs b/crates/openhuman-core/src/core/runtime/services.rs
index 58409fefe9..d7b26cb84a 100644
--- a/crates/openhuman-core/src/core/runtime/services.rs
+++ b/crates/openhuman-core/src/core/runtime/services.rs
@@ -377,11 +377,8 @@ fn spawn_module_preload(_config: &Config) {
log::debug!("[runtime.bootstrap] native module preload skipped: modules are compiled out");
}
-/// Runs startup housekeeping, then starts one-shot boot background work
-/// selected by [`ServiceSet`].
+/// Starts one-shot boot background work selected by [`ServiceSet`].
pub async fn start_boot_once_jobs(services: ServiceSet, config: &Config) {
- run_legacy_migrations(config).await;
-
// The orphaned-run sweep does NOT live here. It runs in
// `CoreBuilder::build`, which every runtime goes through — these jobs only
// run from `serve()`, so a build-only embedder would never be swept.
@@ -415,7 +412,9 @@ pub async fn start_boot_once_jobs(services: ServiceSet, config: &Config) {
}
}
-async fn run_legacy_migrations(config: &Config) {
+/// Migrates legacy durable agent state before a built runtime can expose its
+/// crate-backed stores to in-process or HTTP callers.
+pub(crate) async fn run_legacy_migrations(config: &Config) {
match crate::cron::seed::prune_retired_jobs(config) {
Ok(count) if count > 0 => {
log::info!("[cron] removed {count} retired autopilot job(s)");