Skip to content

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

feat(caps_host): cancel binding token when registration drops

Steven Enamakele6595f156059
diff --git a/crates/openhuman-core/src/flows/caps_host/binding.rs b/crates/openhuman-core/src/flows/caps_host/binding.rs
index 8f938baf20..0066213cee 100644
--- a/crates/openhuman-core/src/flows/caps_host/binding.rs
+++ b/crates/openhuman-core/src/flows/caps_host/binding.rs
@@ -28,10 +28,17 @@ pub(crate) struct CapsHostBinding {
pub(crate) run_id: String,
pub(crate) security: Arc<crate::security::SecurityPolicy>,
pub(crate) approval: crate::security::approval::ApprovalTurnContext,
+ pub(crate) cancellation: tokio_util::sync::CancellationToken,
pub(crate) agent_runs:
tokio::sync::Mutex<HashMap<String, Arc<tokio::sync::Mutex<AgentRunState>>>>,
}
+impl Drop for CapsHostRegistration {
+ fn drop(&mut self) {
+ self._binding.cancellation.cancel();
+ }
+}
+
impl CapsHostBinding {
/// Re-enter the request's captured tenant, identity and turn origin for a
/// bus callback that runs on the module runtime.
@@ -85,6 +92,7 @@ pub(crate) async fn serve(
run_id,
security,
approval,
+ cancellation: tokio_util::sync::CancellationToken::new(),
agent_runs: tokio::sync::Mutex::new(HashMap::new()),
});
let path = format!(