The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(subagent): move the pause-checkpoint writer to its own module\n\n`scripts/ci/check-openhuman-rust-layout.mjs` pins `runner.rs` at 1769 lines\nand `progress_bridge.rs` at 1547 as legacy exceptions, and the gate is\ndeliberately monotonic — a pinned file may not grow. Adding\n`write_pause_checkpoint` pushed runner.rs to 1801 and the ledger comment\npushed progress_bridge.rs to 1550, so both tripped it.\n\nThe writer moves to `ops/pause_checkpoint.rs` (named to distinguish it from\nthe existing `ops/checkpoint.rs`, which summarises a cap-hit run rather than\npersisting a pause), taking its tests with it. `progress_bridge.rs` drops the\nnow-redundant local by asking `checkpoint_path` directly.\n\nNo behaviour change.\n
Shanu8fb5818801dc
diff --git a/src/openhuman/agent/harness/subagent_runner/ops/mod.rs b/src/openhuman/agent/harness/subagent_runner/ops/mod.rsindex 80d5ca7929..017589095f 100644--- a/src/openhuman/agent/harness/subagent_runner/ops/mod.rs+++ b/src/openhuman/agent/harness/subagent_runner/ops/mod.rs@@ -15,10 +15,12 @@//! | `prompt.rs` | Role-contract suffix, `append_subagent_role_contract`, `dedup_tool_specs_by_name` |//! | `runner.rs` | `run_subagent`, `run_typed_mode` |//! | `graph.rs` | `run_subagent_via_graph` — the sub-agent turn graph + tools |-//! | `checkpoint.rs` | `SubagentCheckpoint` |+//! | `checkpoint.rs` | `SubagentCheckpoint` — cap-hit summary |+//! | `pause_checkpoint.rs` | `write` — the on-disk pause snapshot for `continue_subagent` |mod checkpoint;mod graph;+mod pause_checkpoint;pub(crate) use graph::run_agent_turn_request_via_default_graph;mod prompt;mod provider;diff --git a/src/openhuman/agent/harness/subagent_runner/ops/pause_checkpoint.rs b/src/openhuman/agent/harness/subagent_runner/ops/pause_checkpoint.rsnew file mode 100644index 0000000000..58761b0e16--- /dev/null+++ b/src/openhuman/agent/harness/subagent_runner/ops/pause_checkpoint.rs@@ -0,0 +1,74 @@+//! Persisting a paused sub-agent so `continue_subagent` can resume it.+//!+//! Distinct from [`super::checkpoint`], which summarises a *cap-hit* run into+//! resumable prose. This one is the on-disk conversation snapshot written when+//! a child exits early on `ask_user_clarification`.++/// Persist a paused sub-agent's conversation so `continue_subagent` can resume+/// it, returning the path actually written or `None` when it could not be.+///+/// Every failure here is logged at `error`, not `warn`. A checkpoint that was+/// not written is not a degraded nicety: the run is about to be reported as+/// `AwaitingUser`, the orchestrator will relay a `task_id` and ask the user to+/// answer, and the loss only becomes visible after they have — at which point+/// the answer has nowhere to go. That late, invisible failure is what #5928's+/// first acceptance criterion is about, and the `Option` this returns is what+/// lets the caller stop promising a resumable pause it did not achieve.+///+/// Its own module so each failure branch is reachable from a test, and so+/// `runner.rs` stays under the layout gate's line pin: point `checkpoint_dir` at a path that cannot be created, or at one+/// whose target file cannot be written.+pub(super) fn write(+ checkpoint_dir: &std::path::Path,+ task_id: &str,+ data: &crate::openhuman::agent::harness::subagent_runner::types::SubagentCheckpointData,+) -> Option<std::path::PathBuf> {+ if let Err(e) = std::fs::create_dir_all(checkpoint_dir) {+ tracing::error!(+ task_id = %task_id,+ dir = %checkpoint_dir.display(),+ error = %e,+ "[subagent_runner] could not create the checkpoint directory; this pause will not be \+ resumable from disk"+ );+ return None;+ }++ let json = match serde_json::to_string_pretty(data) {+ Ok(json) => json,+ Err(e) => {+ tracing::error!(+ task_id = %task_id,+ error = %e,+ "[subagent_runner] could not serialize the checkpoint; this pause will not be \+ resumable from disk"+ );+ return None;+ }+ };++ let checkpoint_path = checkpoint_dir.join(format!("{task_id}.json"));+ if let Err(e) = std::fs::write(&checkpoint_path, json) {+ tracing::error!(+ task_id = %task_id,+ path = %checkpoint_path.display(),+ error = %e,+ "[subagent_runner] could not write the checkpoint; this pause will not be resumable \+ from disk"+ );+ return None;+ }++ tracing::info!(+ task_id = %task_id,+ path = %checkpoint_path.display(),+ history_len = data.history.len(),+ "[subagent_runner] checkpoint written for awaiting_user"+ );+ Some(checkpoint_path)+}+++#[cfg(test)]+#[path = "runner_checkpoint_tests.rs"]+mod tests;diff --git a/src/openhuman/agent/harness/subagent_runner/ops/runner.rs b/src/openhuman/agent/harness/subagent_runner/ops/runner.rsindex 7a4a4b8d4e..8c99baef95 100644--- a/src/openhuman/agent/harness/subagent_runner/ops/runner.rs+++ b/src/openhuman/agent/harness/subagent_runner/ops/runner.rs@@ -1657,7 +1657,8 @@ async fn run_typed_mode(model_override: options.model_override.clone(),created_at: chrono::Utc::now().to_rfc3339(),};- let checkpoint = write_pause_checkpoint(&checkpoint_dir, task_id, &checkpoint_data);+ let checkpoint =+ super::pause_checkpoint::write(&checkpoint_dir, task_id, &checkpoint_data);crate::openhuman::agent::harness::subagent_runner::types::SubagentRunStatus::AwaitingUser {question,@@ -1728,74 +1729,7 @@ async fn run_typed_mode(})}-/// Persist a paused sub-agent's conversation so `continue_subagent` can resume-/// it, returning the path actually written or `None` when it could not be.-///-/// Every failure here is logged at `error`, not `warn`. A checkpoint that was-/// not written is not a degraded nicety: the run is about to be reported as-/// `AwaitingUser`, the orchestrator will relay a `task_id` and ask the user to-/// answer, and the loss only becomes visible after they have — at which point-/// the answer has nowhere to go. That late, invisible failure is what #5928's-/// first acceptance criterion is about, and the `Option` this returns is what-/// lets the caller stop promising a resumable pause it did not achieve.-///-/// Split out as a free function so each failure branch is reachable from a-/// test: point `checkpoint_dir` at a path that cannot be created, or at one-/// whose target file cannot be written.-fn write_pause_checkpoint(- checkpoint_dir: &std::path::Path,- task_id: &str,- data: &crate::openhuman::agent::harness::subagent_runner::types::SubagentCheckpointData,-) -> Option<std::path::PathBuf> {- if let Err(e) = std::fs::create_dir_all(checkpoint_dir) {- tracing::error!(- task_id = %task_id,- dir = %checkpoint_dir.display(),- error = %e,- "[subagent_runner] could not create the checkpoint directory; this pause will not be \- resumable from disk"- );- return None;- }-- let json = match serde_json::to_string_pretty(data) {- Ok(json) => json,- Err(e) => {- tracing::error!(- task_id = %task_id,- error = %e,- "[subagent_runner] could not serialize the checkpoint; this pause will not be \- resumable from disk"- );- return None;- }- };-- let checkpoint_path = checkpoint_dir.join(format!("{task_id}.json"));- if let Err(e) = std::fs::write(&checkpoint_path, json) {- tracing::error!(- task_id = %task_id,- path = %checkpoint_path.display(),- error = %e,- "[subagent_runner] could not write the checkpoint; this pause will not be resumable \- from disk"- );- return None;- }-- tracing::info!(- task_id = %task_id,- path = %checkpoint_path.display(),- history_len = data.history.len(),- "[subagent_runner] checkpoint written for awaiting_user"- );- Some(checkpoint_path)-}-#[cfg(test)]#[path = "runner_fast_path_tests_tests.rs"]mod fast_path_tests;-#[cfg(test)]-#[path = "runner_checkpoint_tests.rs"]-mod checkpoint_tests;diff --git a/src/openhuman/agent/harness/subagent_runner/ops/runner_checkpoint_tests.rs b/src/openhuman/agent/harness/subagent_runner/ops/runner_checkpoint_tests.rsindex 642a4eb4fd..71d3a39ba1 100644--- a/src/openhuman/agent/harness/subagent_runner/ops/runner_checkpoint_tests.rs+++ b/src/openhuman/agent/harness/subagent_runner/ops/runner_checkpoint_tests.rs@@ -6,7 +6,6 @@//! the orchestrator relayed a `task_id` and asked the user to answer a question//! whose answer had nowhere to go.-use super::write_pause_checkpoint;use crate::openhuman::agent::harness::subagent_runner::types::SubagentCheckpointData;fn checkpoint_data(task_id: &str) -> SubagentCheckpointData {@@ -29,7 +28,7 @@ fn a_written_checkpoint_returns_the_path_it_wrote() {let dir = tempfile::tempdir().expect("tempdir");let checkpoint_dir = dir.path().join("subagent_checkpoints");- let written = write_pause_checkpoint(&checkpoint_dir, "task-1", &checkpoint_data("task-1"))+ let written = super::write(&checkpoint_dir, "task-1", &checkpoint_data("task-1")).expect("a writable directory must produce a checkpoint");assert_eq!(@@ -56,7 +55,7 @@ fn the_directory_is_created_on_demand() {let nested = dir.path().join("a/b/c/subagent_checkpoints");assert!(!nested.exists(), "precondition: nothing has created it");- let written = write_pause_checkpoint(&nested, "task-2", &checkpoint_data("task-2"))+ let written = super::write(&nested, "task-2", &checkpoint_data("task-2")).expect("a missing directory must be created, not treated as a failure");assert!(written.is_file());@@ -71,7 +70,7 @@ fn an_uncreatable_directory_reports_no_checkpoint() {std::fs::write(&blocked, b"i am a file").expect("seed the blocker");assert!(- write_pause_checkpoint(&blocked, "task-3", &checkpoint_data("task-3")).is_none(),+ super::write(&blocked, "task-3", &checkpoint_data("task-3")).is_none(),"a checkpoint directory that cannot exist must report no checkpoint, \not a silently dropped warning");@@ -86,7 +85,7 @@ fn an_unwritable_target_reports_no_checkpoint() {std::fs::create_dir_all(checkpoint_dir.join("task-4.json")).expect("occupy the target path");assert!(- write_pause_checkpoint(&checkpoint_dir, "task-4", &checkpoint_data("task-4")).is_none(),+ super::write(&checkpoint_dir, "task-4", &checkpoint_data("task-4")).is_none(),"a checkpoint whose write fails must report no checkpoint");}diff --git a/src/openhuman/web_chat/progress_bridge.rs b/src/openhuman/web_chat/progress_bridge.rsindex 8762f889b1..77a7ee5625 100644--- a/src/openhuman/web_chat/progress_bridge.rs+++ b/src/openhuman/web_chat/progress_bridge.rs@@ -1001,12 +1001,6 @@ pub(crate) fn spawn_progress_bridge(thread_id,request_id,);- // Use the path the runner actually wrote, not one rebuilt- // from the workspace dir. The rebuilt path was recorded- // unconditionally, so the ledger asserted a checkpoint- // existed even when the write had failed, and it ignored- // any `checkpoint_dir` override (#5928).- let checkpoint_present = checkpoint_path.is_some();ledger_upsert_agent_run(&config,AgentRunUpsert {@@ -1024,6 +1018,9 @@ pub(crate) fn spawn_progress_bridge(worker_thread_id: worker_thread_id.clone(),task_board_id: Some(thread_id.clone()),task_card_id: None,+ // What the runner actually wrote; the old rebuild+ // from `workspace_dir` asserted a checkpoint that+ // may never have been written (#5928).checkpoint_path: checkpoint_path.clone(),checkpoint: Some(json!({"resumeTool": "continue_subagent",@@ -1031,7 +1028,7 @@ pub(crate) fn spawn_progress_bridge("agentId": agent_id,"question": question,"workerThreadId": worker_thread_id,- "checkpointPersisted": checkpoint_present+ "checkpointPersisted": checkpoint_path.is_some()})),summary: Some(question.clone()),error: None,