Skip to content

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

feat(skills): add workflow run tool and blob sweep

Steven Enamakelf7dd7512b5a0
diff --git a/crates/openhuman-core/src/agent/tools/run_workflow.rs b/crates/openhuman-core/src/agent/tools/run_workflow.rs
index f45f5ca99a..6bf10cdd26 100644
--- a/crates/openhuman-core/src/agent/tools/run_workflow.rs
+++ b/crates/openhuman-core/src/agent/tools/run_workflow.rs
@@ -344,7 +344,7 @@ impl Tool for RunWorkflowTool {
// Fire-and-forget: only the spawn backstop applies — no await, so no
// re-entrancy/nesting slot to take.
if wait_seconds == 0 {
- return match spawn_workflow_run_background(workflow_id.clone(), inputs, origin).await {
+ return match spawn_workflow_run_background(&dispatch, workflow_id.clone(), inputs, origin).await {
// Count only spawns that actually start against the backstop —
// unknown-workflow / bad-input rejections (the Err arm) must not
// burn the budget, or rejected calls accumulate and trip the
@@ -378,7 +378,7 @@ impl Tool for RunWorkflowTool {
Err(e) => return Ok(ToolResult::error(format!("run_workflow: {e}"))),
};
- let started = match spawn_workflow_run_background(workflow_id.clone(), inputs, origin).await
+ let started = match spawn_workflow_run_background(&dispatch, workflow_id.clone(), inputs, origin).await
{
Ok(s) => {
if let Err(e) = guard::account_spawn(&dispatch) {
diff --git a/crates/openhuman-core/src/skills/runtime/run_machinery.rs b/crates/openhuman-core/src/skills/runtime/run_machinery.rs
index d17fb2f301..6f91da54ca 100644
--- a/crates/openhuman-core/src/skills/runtime/run_machinery.rs
+++ b/crates/openhuman-core/src/skills/runtime/run_machinery.rs
@@ -38,6 +38,7 @@ pub struct WorkflowRunStarted {
/// missing required inputs) surface as `Err(String)` *before* the spawn so
/// callers can reject malformed invocations synchronously.
pub async fn spawn_workflow_run_background(
+ ctx: &crate::core::runtime::DispatchCtx,
skill_id_param: String,
inputs_param: Option<Value>,
parent_origin: Option<crate::agent::turn_origin::AgentTurnOrigin>,
@@ -157,6 +158,7 @@ pub async fn spawn_workflow_run_background(
let inputs = inputs.clone();
let log_path = log_path.clone();
let inherited_origin = inherited_origin.clone();
+ let ctx = ctx.clone();
tokio::spawn(async move {
if let Err(e) =
run_log::write_header(&log_path, &workflow_id, &run_id, &inputs, &task_prompt).await
@@ -183,7 +185,7 @@ pub async fn spawn_workflow_run_background(
config.http_request.allowed_domains = vec!["*".to_string()];
}
let mut agent = match OpenHumanSessionHost::from_config_for_agent(
- &crate::core::runtime::DispatchCtx::ambient(),
+ &ctx,
&config,
"orchestrator",
) {
diff --git a/crates/openhuman-core/src/skills/runtime/schemas.rs b/crates/openhuman-core/src/skills/runtime/schemas.rs
index 607076af21..481029f336 100644
--- a/crates/openhuman-core/src/skills/runtime/schemas.rs
+++ b/crates/openhuman-core/src/skills/runtime/schemas.rs
@@ -273,7 +273,7 @@ fn handle_run(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture
.unwrap_or(crate::agent::turn_origin::AgentTurnOrigin::Cli);
let started = crate::agent::turn_origin::with_origin(
origin.clone(),
- spawn_workflow_run_background(payload.skill_id, payload.inputs, Some(origin)),
+ spawn_workflow_run_background(&ctx, payload.skill_id, payload.inputs, Some(origin)),
)
.await?;
to_json(Outcome::new(
diff --git a/crates/openhuman-core/src/skills/schemas/handlers.rs b/crates/openhuman-core/src/skills/schemas/handlers.rs
index 72d253b172..14231a016c 100644
--- a/crates/openhuman-core/src/skills/schemas/handlers.rs
+++ b/crates/openhuman-core/src/skills/schemas/handlers.rs
@@ -170,7 +170,7 @@ pub(super) fn handle_skills_run(ctx: DispatchCtx, params: Map<String, Value>) ->
.unwrap_or(crate::agent::turn_origin::AgentTurnOrigin::Cli);
let started = match crate::agent::turn_origin::with_origin(
origin.clone(),
- spawn_workflow_run_background(payload.workflow_id, payload.inputs, Some(origin)),
+ spawn_workflow_run_background(&ctx, payload.workflow_id, payload.inputs, Some(origin)),
)
.await
{
diff --git a/crates/openhuman-core/src/storage/blob_sweep.rs b/crates/openhuman-core/src/storage/blob_sweep.rs
index 145a3c2791..8b94109376 100644
--- a/crates/openhuman-core/src/storage/blob_sweep.rs
+++ b/crates/openhuman-core/src/storage/blob_sweep.rs
@@ -100,7 +100,7 @@ pub(crate) async fn sweep_profiles(backend: &dyn StorageBackend, profile_ids: &[
/// Agent scopes are enumerated from the installed backend (the only caller,
/// [`sweep_installed`], passes that one).
pub async fn sweep_all(backend: Arc<dyn StorageBackend>) -> u64 {
- let scoped: u64 = super::agents::for_each_scope(&crate::core::runtime::DispatchCtx::host_default(), "blob sweep", |_| {
+ let scoped: u64 = super::agents::for_each_scope(&crate::core::runtime::DispatchCtx::host_default(), "blob sweep", |ctx| {
let backend = Arc::clone(&backend);
async move {
match super::current_scope() {
@@ -108,7 +108,7 @@ pub async fn sweep_all(backend: Arc<dyn StorageBackend>) -> u64 {
// Modules keep their expiring blobs in their own scopes
// derived from the acting scope (TinyJuice's CCR TTL).
let mut removed = sweep_scope(backend.as_ref(), &scope).await;
- for module_scope in crate::modules::expiring_blob_module_scopes() {
+ for module_scope in crate::modules::expiring_blob_module_scopes(&ctx) {
if module_scope != scope {
removed += sweep_scope(backend.as_ref(), &module_scope).await;
}