Skip to content

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

fix(caps_host): return Pending for workflow approval requests

Steven Enamakel975ef4a99a0e
diff --git a/crates/openhuman-core/src/flows/caps_host/mod.rs b/crates/openhuman-core/src/flows/caps_host/mod.rs
index 55a909e2f0..61798ff9f1 100644
--- a/crates/openhuman-core/src/flows/caps_host/mod.rs
+++ b/crates/openhuman-core/src/flows/caps_host/mod.rs
@@ -19,6 +19,7 @@ pub(crate) use http::{
OpenHumanHttp, resolve_http_credential,
};
pub(crate) use llm::{OpenHumanLlm, resolve_host_model};
+pub(crate) use memory::OpenHumanMemory;
pub(crate) use prompt::model_response_to_completion_value;
pub(crate) use service::CapsHostService;
pub(crate) use tools::OpenHumanTools;
diff --git a/crates/openhuman-core/src/flows/caps_host/service.rs b/crates/openhuman-core/src/flows/caps_host/service.rs
index a2b14d4514..b66137ec78 100644
--- a/crates/openhuman-core/src/flows/caps_host/service.rs
+++ b/crates/openhuman-core/src/flows/caps_host/service.rs
@@ -5,7 +5,6 @@ use std::sync::Arc;
use serde_json::{Value, json};
use tinyflows_bus::runs::{self, caps as members};
-use crate::config::Config;
use crate::security::credentials::HttpCredentialsStore;
use super::binding::CapsHostBinding;
@@ -344,17 +343,30 @@ impl CapsHostService {
async fn approval_decide(
&self,
- _request: runs::ApprovalRequest,
+ request: runs::ApprovalRequest,
) -> tinybus::Result<runs::ApprovalOutcome> {
- Err(tinybus::Error::failed(
- "workflow approval callback is unavailable",
- ))
+ if request
+ .run_id
+ .as_deref()
+ .is_some_and(|run_id| run_id != self.0.run_id.as_str())
+ {
+ return Err(tinybus::Error::failed(
+ "workflow approval request does not match its bound run",
+ ));
+ }
+ // The module owns graph approval rows and projects them through the
+ // durable run record. Repeated calls intentionally return Pending;
+ // the module retries this request after `Runs.ResumeRun` carries the
+ // human's node decision. Acting-tool approvals remain on ApprovalGate.
+ Ok(runs::ApprovalOutcome::Pending)
}
async fn approval_cancel(
&self,
_request: runs::ApprovalCancelRequest,
) -> tinybus::Result<()> {
+ // Graph approval rows are module-owned; cancellation is represented
+ // by the module's run lifecycle and does not cancel tool approvals.
Ok(())
}
}
@@ -375,7 +387,6 @@ fn bus_error(error: impl std::fmt::Display) -> tinybus::Error {
fn to_bus_agent_definition(
definition: crate::agent::harness::host_definition::AgentDefinition,
) -> Result<runs::AgentDefinition, String> {
- use crate::agent::harness::host_definition::AgentDefinitionExt;
use tinyagents_definition::{ModelSpec, PromptSource, ToolScope};
let instructions = match &definition.system_prompt {
@@ -399,7 +410,6 @@ fn to_bus_agent_definition(
})
.collect(),
};
- let _ = definition.prompt_fn();
Ok(runs::AgentDefinition {
id: definition.id.clone(),
name: definition
diff --git a/crates/openhuman-core/src/modules/tinyflows_tests.rs b/crates/openhuman-core/src/modules/tinyflows_tests.rs
index 7a45499be2..60fd1a6883 100644
--- a/crates/openhuman-core/src/modules/tinyflows_tests.rs
+++ b/crates/openhuman-core/src/modules/tinyflows_tests.rs
@@ -207,3 +207,48 @@ async fn cancelling_partial_callback_registration_unserves_and_releases_its_cont
);
assert!(proxy.call::<serde_json::Value>("Ping", ()).await.is_err());
}
+
+#[cfg(feature = "modules")]
+#[tokio::test]
+async fn single_callback_registration_unserves_when_its_guard_drops() {
+ use std::sync::Arc;
+
+ let path = format!(
+ "/ai/tinyhumans/openhuman/TestRegistration/{}",
+ uuid::Uuid::new_v4().simple()
+ );
+ let dropped = Arc::new(tokio::sync::Notify::new());
+ let context = Arc::new(());
+ let weak_context = Arc::downgrade(&context);
+ let registration = serve_registered(
+ path.clone(),
+ RegistrationProbe {
+ dropped: Arc::clone(&dropped),
+ context: Arc::clone(&context),
+ },
+ )
+ .await
+ .expect("single callback registration succeeds");
+
+ let runtime = super::super::runtime::runtime()
+ .await
+ .expect("module runtime exists");
+ let proxy = runtime
+ .connection()
+ .proxy(
+ HOST_BUS_NAME,
+ &path,
+ "ai.tinyhumans.openhuman.TestRegistration",
+ )
+ .expect("probe proxy");
+ assert!(proxy.call::<serde_json::Value>("Ping", ()).await.is_ok());
+
+ drop(registration);
+ let cleanup = dropped.notified();
+ tokio::time::timeout(std::time::Duration::from_secs(5), cleanup)
+ .await
+ .expect("registration guard drop removes its interface");
+ drop(context);
+ assert!(weak_context.upgrade().is_none(), "callback context is released");
+ assert!(proxy.call::<serde_json::Value>("Ping", ()).await.is_err());
+}