Skip to content

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

refactor(core): clean up error handling in scheduler and host

Steven Enamakel8b626734f9b6
diff --git a/crates/openhuman-core/src/cron/scheduler.rs b/crates/openhuman-core/src/cron/scheduler.rs
index f19ea501fc..d0e9df0605 100644
--- a/crates/openhuman-core/src/cron/scheduler.rs
+++ b/crates/openhuman-core/src/cron/scheduler.rs
@@ -290,17 +290,18 @@ async fn execute_via_bus(
wait: true,
};
tracing::debug!(job_id = %job.id, %run_id, "[cron:scheduler] RunJobNow");
- let reply: RunJobReply = proxy
- .call(members::RUN_JOB_NOW, (request,))
- .await
- .map_err(|error| {
- let message = error.wire_message();
- if message.contains(ALREADY_RUNNING) {
- anyhow!("cron job '{}' is already running", job.id)
- } else {
- anyhow!(message)
- }
- })?;
+ let reply: RunJobReply =
+ proxy
+ .call(members::RUN_JOB_NOW, (request,))
+ .await
+ .map_err(|error| {
+ let message = error.wire_message();
+ if message.contains(ALREADY_RUNNING) {
+ anyhow!("cron job '{}' is already running", job.id)
+ } else {
+ anyhow!(message)
+ }
+ })?;
drop(host);
match reply {
RunJobReply::Completed { attempt, .. } => Ok(attempt),
@@ -308,10 +309,9 @@ async fn execute_via_bus(
tinyflows_bus::schedule::RunJobRefusal::AlreadyRunning => {
Err(anyhow!("cron job '{}' is already running", job.id))
}
- tinyflows_bus::schedule::RunJobRefusal::DefinitionChanged => Err(anyhow!(
- "cron job '{}' changed before it could run",
- job.id
- )),
+ tinyflows_bus::schedule::RunJobRefusal::DefinitionChanged => {
+ Err(anyhow!("cron job '{}' changed before it could run", job.id))
+ }
},
RunJobReply::Accepted { .. } => Err(anyhow!(
"tinyflows accepted a blocking Run Now request without a terminal result"
diff --git a/crates/openhuman-core/src/flows/builder_host.rs b/crates/openhuman-core/src/flows/builder_host.rs
index 371d55d274..6b8254f13e 100644
--- a/crates/openhuman-core/src/flows/builder_host.rs
+++ b/crates/openhuman-core/src/flows/builder_host.rs
@@ -165,7 +165,10 @@ impl SandboxRunner for FlowsHost {
.await
.map_err(|error| error.to_string())?;
let connection = runtime.connection().clone();
- let path = format!("/ai/tinyhumans/openhuman/FlowSandbox/{}", uuid::Uuid::new_v4());
+ let path = format!(
+ "/ai/tinyhumans/openhuman/FlowSandbox/{}",
+ uuid::Uuid::new_v4()
+ );
let object_path = ObjectPath::new(&path).map_err(|error| error.to_string())?;
let served_path = object_path.clone();
let callback = SandboxToolPreflight {
@@ -173,9 +176,7 @@ impl SandboxRunner for FlowsHost {
};
runtime
.spawn(async move {
- connection
- .request_name(SANDBOX_CALLBACK_BUS)
- .await?;
+ connection.request_name(SANDBOX_CALLBACK_BUS).await?;
connection.serve_at(served_path, callback).await
})
.await
@@ -289,7 +290,6 @@ impl BuilderGates for FlowsHost {
)
.await
}
-
}
#[async_trait]