Skip to content

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

chore(subagent): apply rustfmt formatting to subagent modules

Steven Enamakel4fc76a912061
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs
index bc6af86368..6c718b0039 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs
@@ -17,8 +17,8 @@ use super::types::{
mod driver;
pub use driver::{
cancel_driver_job_by_task, cancel_driver_job_for_observed_session,
- cancel_driver_job_for_session, cancel_driver_jobs_for_thread,
- mark_driver_pause_cancelled, resolve_lifecycle_key, DriverTaskCancellation,
+ cancel_driver_job_for_session, cancel_driver_jobs_for_thread, mark_driver_pause_cancelled,
+ resolve_lifecycle_key, DriverTaskCancellation,
};
pub fn normalize_task_key(input: &str) -> String {
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_driver.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_driver.rs
index f813940d81..c15feff818 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_driver.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_driver.rs
@@ -206,56 +206,56 @@ pub fn cancel_driver_job_by_task(
}
let lifecycle_key = match session.lifecycle_key.clone() {
Some(key) => Some(key),
- None
- if session.current_task_id.is_some()
- && matches!(
- session.status,
- DurableSubagentStatus::Idle
- | DurableSubagentStatus::Running
- | DurableSubagentStatus::AwaitingUser
- ) =>
+ None if session.current_task_id.is_some()
+ && matches!(
+ session.status,
+ DurableSubagentStatus::Idle
+ | DurableSubagentStatus::Running
+ | DurableSubagentStatus::AwaitingUser
+ ) =>
{
Some(
- resolve_lifecycle_key(
- store,
- task_id,
- &session.parent_session,
- session.parent_thread_id.as_deref(),
- checkpoint_dir,
- )
- .map_err(|error| {
- format!("failed to resolve subagent lifecycle for cancellation: {error}")
- })?,
+ resolve_lifecycle_key(
+ store,
+ task_id,
+ &session.parent_session,
+ session.parent_thread_id.as_deref(),
+ checkpoint_dir,
+ )
+ .map_err(|error| {
+ format!("failed to resolve subagent lifecycle for cancellation: {error}")
+ })?,
)
}
None => None,
};
- if lifecycle_key.as_ref().is_some_and(|key| {
- key.task_id != task_id || key.thread_id != session.parent_thread_id
- }) {
+ if lifecycle_key
+ .as_ref()
+ .is_some_and(|key| key.task_id != task_id || key.thread_id != session.parent_thread_id)
+ {
return Ok(None);
}
- let typed_finished = || -> Result<Option<tinyagents_orchestration::subagent::FinishedOutcome>, String> {
- let Some(key) = lifecycle_key.as_ref() else {
- return Ok(None);
- };
- let Some(outcome) = crate::agent::subagent_host::load_terminal_outcome(
- &store.workspace_dir,
- key,
- )? else {
- return Ok(None);
+ let typed_finished =
+ || -> Result<Option<tinyagents_orchestration::subagent::FinishedOutcome>, String> {
+ let Some(key) = lifecycle_key.as_ref() else {
+ return Ok(None);
+ };
+ let Some(outcome) =
+ crate::agent::subagent_host::load_terminal_outcome(&store.workspace_dir, key)?
+ else {
+ return Ok(None);
+ };
+ Ok(match outcome.status {
+ tinyagents_orchestration::subagent::SubagentOutcomeKind::Completed => {
+ Some(tinyagents_orchestration::subagent::FinishedOutcome::Completed)
+ }
+ tinyagents_orchestration::subagent::SubagentOutcomeKind::Incomplete(_) => {
+ Some(tinyagents_orchestration::subagent::FinishedOutcome::Failed)
+ }
+ tinyagents_orchestration::subagent::SubagentOutcomeKind::Cancelled
+ | tinyagents_orchestration::subagent::SubagentOutcomeKind::AwaitingInput(_) => None,
+ })
};
- Ok(match outcome.status {
- tinyagents_orchestration::subagent::SubagentOutcomeKind::Completed => {
- Some(tinyagents_orchestration::subagent::FinishedOutcome::Completed)
- }
- tinyagents_orchestration::subagent::SubagentOutcomeKind::Incomplete(_) => {
- Some(tinyagents_orchestration::subagent::FinishedOutcome::Failed)
- }
- tinyagents_orchestration::subagent::SubagentOutcomeKind::Cancelled
- | tinyagents_orchestration::subagent::SubagentOutcomeKind::AwaitingInput(_) => None,
- })
- };
let already_finished = match session.status {
DurableSubagentStatus::Idle => {
let finished = typed_finished()?;
@@ -444,4 +444,4 @@ pub fn resolve_lifecycle_key(
return Err("durable subagent lifecycle key does not match its owned session".into());
}
Ok(key)
-}
\ No newline at end of file
+}
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_workspace_owner_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_workspace_owner_tests.rs
index 3b678d3bac..027294529f 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_workspace_owner_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_workspace_owner_tests.rs
@@ -2,10 +2,10 @@ use super::*;
#[tokio::test]
async fn driver_job_controls_are_isolated_by_workspace_with_shared_runtime_state() {
- use crate::agent::subagent_host::{run_subagent_via_driver_tool, SubagentRunOptions};
use crate::agent::orchestration::subagent_sessions::{
DurableSubagentSession, DurableSubagentStatus, SubagentSessionStore,
};
+ use crate::agent::subagent_host::{run_subagent_via_driver_tool, SubagentRunOptions};
use crate::core::runtime::{ContextOverlay, CoreContext, DomainSet};
use crate::tools::toolpacks::ToolGroups;
use tinyagents_harness::agent_loop::phases::execute_tool_batch;
@@ -68,9 +68,7 @@ async fn driver_job_controls_are_isolated_by_workspace_with_shared_runtime_state
options.task_id = Some("same-raw-task-id".into());
options.thread_id = Some("same-parent-thread".into());
options.run_context.thread_id = Some("same-parent-thread".into());
- options.run_context = options
- .run_context
- .with_core(Some(Arc::clone(core)));
+ options.run_context = options.run_context.with_core(Some(Arc::clone(core)));
let run_id = workspace
.file_name()
.and_then(std::ffi::OsStr::to_str)
@@ -96,8 +94,10 @@ async fn driver_job_controls_are_isolated_by_workspace_with_shared_runtime_state
tinyagents_harness::context::RunConfig::new("workspace-b-control")
.with_thread("same-parent-thread"),
);
- let jobs_a = crate::core::runtime::slot_for::<SubAgentJobRegistry>(&parent_a.data.dispatch_ctx());
- let jobs_b = crate::core::runtime::slot_for::<SubAgentJobRegistry>(&parent_b.data.dispatch_ctx());
+ let jobs_a =
+ crate::core::runtime::slot_for::<SubAgentJobRegistry>(&parent_a.data.dispatch_ctx());
+ let jobs_b =
+ crate::core::runtime::slot_for::<SubAgentJobRegistry>(&parent_b.data.dispatch_ctx());
assert!(
Arc::ptr_eq(&jobs_a, &jobs_b),
"the two workspace overlays must exercise one shared registry"
@@ -190,14 +190,17 @@ async fn driver_job_controls_are_isolated_by_workspace_with_shared_runtime_state
.expect("workspace B child is registered");
let id_a = job_a.id.as_str().to_owned();
let id_b = job_b.id.as_str().to_owned();
- assert_ne!(id_a, id_b, "full lifecycle scope keeps raw-ID reuse distinct");
+ assert_ne!(
+ id_a, id_b,
+ "full lifecycle scope keeps raw-ID reuse distinct"
+ );
let now = chrono::Utc::now().to_rfc3339();
- let save_running_session = |workspace: &std::path::Path,
- session_id: &str,
- task_key: tinyagents_orchestration::subagent::SubagentTaskKey| {
- SubagentSessionStore::new(workspace.to_path_buf())
- .save(&[DurableSubagentSession {
+ let save_running_session =
+ |workspace: &std::path::Path,
+ session_id: &str,
+ task_key: tinyagents_orchestration::subagent::SubagentTaskKey| {
+ SubagentSessionStore::new(workspace.to_path_buf()).save(&[DurableSubagentSession {
subagent_session_id: session_id.to_owned(),
parent_session: "same-parent-session".into(),
parent_thread_id: Some("same-parent-thread".into()),
@@ -219,7 +222,7 @@ async fn driver_job_controls_are_isolated_by_workspace_with_shared_runtime_state
updated_at: now.clone(),
last_used_at: now.clone(),
}])
- };
+ };
save_running_session(&workspace_a, "workspace-a-session", key_a)
.expect("persist A session for native close alias");
save_running_session(&workspace_b, "workspace-b-session", key_b)
@@ -235,8 +238,7 @@ async fn driver_job_controls_are_isolated_by_workspace_with_shared_runtime_state
let mut harness: tinyagents_harness::runtime::AgentHarness<
(),
crate::agent::tinyagents::host::OpenHumanRunContext,
- > =
- tinyagents_harness::runtime::AgentHarness::new();
+ > = tinyagents_harness::runtime::AgentHarness::new();
crate::agent::tinyagents::tool_registration::host_tool_set_builder(
&sets,
&None,
@@ -271,9 +273,7 @@ async fn driver_job_controls_are_isolated_by_workspace_with_shared_runtime_state
)
.await
.expect("native list alias works for A");
- assert!(listed_a.results[0]
- .text()
- .contains("workspace-a-session"));
+ assert!(listed_a.results[0].text().contains("workspace-a-session"));
assert!(
!listed_a.results[0].text().contains("workspace-b-session"),
"A must not see B's durable session: {}",
@@ -294,12 +294,8 @@ async fn driver_job_controls_are_isolated_by_workspace_with_shared_runtime_state
)
.await
.expect("native list alias works for B");
- assert!(listed_b.results[0]
- .text()
- .contains("workspace-b-session"));
- assert!(!listed_b.results[0]
- .text()
- .contains("workspace-a-session"));
+ assert!(listed_b.results[0].text().contains("workspace-b-session"));
+ assert!(!listed_b.results[0].text().contains("workspace-a-session"));
let foreign_wait = execute_tool_batch(
&harness,
@@ -323,7 +319,10 @@ async fn driver_job_controls_are_isolated_by_workspace_with_shared_runtime_state
"A must receive a selector denial for B's generic job id, got: {foreign_wait_text}"
);
assert_eq!(
- jobs_b.get(&id_b).expect("B child remains registered").status,
+ jobs_b
+ .get(&id_b)
+ .expect("B child remains registered")
+ .status,
tinyagents_orchestration::subagent::SubAgentJobStatus::Running,
"a foreign wait must not settle or mutate B's child"
);
@@ -345,7 +344,10 @@ async fn driver_job_controls_are_isolated_by_workspace_with_shared_runtime_state
.expect("foreign close is a recoverable model-facing selector error");
assert!(!foreign_close.results[0].text().contains("\"closed\":true"));
let job_b = jobs_b.get(&id_b).expect("B's child remains registered");
- assert_eq!(job_b.status, tinyagents_orchestration::subagent::SubAgentJobStatus::Running);
+ assert_eq!(
+ job_b.status,
+ tinyagents_orchestration::subagent::SubAgentJobStatus::Running
+ );
let owned_close = execute_tool_batch(
&harness,
@@ -389,14 +391,19 @@ async fn driver_job_controls_are_isolated_by_workspace_with_shared_runtime_state
outcome.status,
crate::agent::subagent_host::SubagentRunStatus::Cancelled
)),
- Err(error) => assert_eq!(error.to_string(), "tinyagents harness run failed: run cancelled"),
+ Err(error) => assert_eq!(
+ error.to_string(),
+ "tinyagents harness run failed: run cancelled"
+ ),
}
assert_eq!(
- jobs_b.get(&id_b).expect("B driver job remains inspectable").status,
+ jobs_b
+ .get(&id_b)
+ .expect("B driver job remains inspectable")
+ .status,
tinyagents_orchestration::subagent::SubAgentJobStatus::Cancelled,
"the shared driver registry is authoritative for B's cancellation"
);
assert!(!parent_cancel_a.is_cancelled());
assert!(!parent_cancel_b.is_cancelled());
}
-
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
index c7364fc36f..e97a1cc18b 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
@@ -69,9 +69,8 @@ pub(crate) fn load_terminal_outcome(
workspace_dir: &std::path::Path,
key: &SubagentTaskKey,
) -> Result<Option<SubagentOutcome>, String> {
- let checkpoint_dir = absolute_checkpoint_dir(
- workspace_dir.join(".openhuman/subagent_checkpoints"),
- );
+ let checkpoint_dir =
+ absolute_checkpoint_dir(workspace_dir.join(".openhuman/subagent_checkpoints"));
OpenHumanPersistence::new(checkpoint_dir)
.terminal_outcome(key)
.map_err(|error| format!("failed to load subagent terminal outcome: {error}"))
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle_terminal_tests.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle_terminal_tests.rs
index afa41573e0..f24503c15a 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle_terminal_tests.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle_terminal_tests.rs
@@ -11,9 +11,7 @@ async fn driver_cancel_uses_the_typed_terminal_for_lossy_idle_sessions() {
let workspace = directory.path();
let store = SubagentSessionStore::new(workspace.to_path_buf());
let jobs = tinyagents_orchestration::subagent::SubAgentJobRegistry::default();
- let persistence = OpenHumanPersistence::new(
- workspace.join(".openhuman/subagent_checkpoints"),
- );
+ let persistence = OpenHumanPersistence::new(workspace.join(".openhuman/subagent_checkpoints"));
for (task_id, terminal, expected) in [
(
@@ -58,7 +56,10 @@ async fn driver_cancel_uses_the_typed_terminal_for_lossy_idle_sessions() {
.unwrap();
let mut outcome = SubagentOutcome::cancelled(task_id);
outcome.status = terminal;
- persistence.record_terminal(&key, &outcome, None).await.unwrap();
+ persistence
+ .record_terminal(&key, &outcome, None)
+ .await
+ .unwrap();
mark_finished(
&store,
&session.subagent_session_id,
@@ -78,15 +79,9 @@ async fn driver_cancel_uses_the_typed_terminal_for_lossy_idle_sessions() {
"both typed terminal outcomes share the legacy Idle session state"
);
- let selected = cancel_driver_job_by_task(
- &store,
- workspace,
- &jobs,
- task_id,
- None,
- )
- .unwrap()
- .expect("typed terminal remains reportable");
+ let selected = cancel_driver_job_by_task(&store, workspace, &jobs, task_id, None)
+ .unwrap()
+ .expect("typed terminal remains reportable");
assert_eq!(selected.already_finished, expected, "{task_id}");
}
}
diff --git a/crates/openhuman-core/src/agent/subagent_host/mod.rs b/crates/openhuman-core/src/agent/subagent_host/mod.rs
index 0991d40c91..e4d0842b99 100644
--- a/crates/openhuman-core/src/agent/subagent_host/mod.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/mod.rs
@@ -57,8 +57,8 @@ mod persisted_compat_tests;
// Public API — the entry point and the shapes it returns.
pub use autonomous::{definition_iter_cap, subagent_iter_cap_with_autonomous_lift};
pub(crate) use lifecycle::detached_subagent_parent;
-pub(crate) use lifecycle::load_terminal_outcome;
pub(crate) use lifecycle::load_subagent_checkpoint;
+pub(crate) use lifecycle::load_terminal_outcome;
pub(crate) use lifecycle::run_configured_delegate_via_driver_tool;
pub(crate) use lifecycle::run_subagent_via_driver_tool;
pub(crate) use lifecycle::spawn_async_via_driver_tool;
diff --git a/crates/openhuman-core/src/agent_runs/subagent_control_tests.rs b/crates/openhuman-core/src/agent_runs/subagent_control_tests.rs
index 65e1a3d05f..b0da293296 100644
--- a/crates/openhuman-core/src/agent_runs/subagent_control_tests.rs
+++ b/crates/openhuman-core/src/agent_runs/subagent_control_tests.rs
@@ -148,7 +148,7 @@ async fn cancelling_a_paused_driver_queues_a_failed_delivery_with_reason() {
forget_workspace_for_test, pending_for,
};
use crate::agent::orchestration::subagent_sessions::{
- mark_finished, upsert_running, DurableSubagentStatus, DriverTaskCancellation,
+ mark_finished, upsert_running, DriverTaskCancellation, DurableSubagentStatus,
SubagentSessionSelector, SubagentSessionStore, SubagentSessionUpsert,
};
use tinyagents_orchestration::subagent::SubagentTaskKey;