Skip to content

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

fix(caps_host): reject agent requests from another workflow run

Steven Enamakel6015db60935c
diff --git a/crates/openhuman-core/src/flows/caps_host/service.rs b/crates/openhuman-core/src/flows/caps_host/service.rs
index 8536f7b877..8b1d953d7d 100644
--- a/crates/openhuman-core/src/flows/caps_host/service.rs
+++ b/crates/openhuman-core/src/flows/caps_host/service.rs
@@ -171,6 +171,16 @@ impl CapsHostService {
&self,
request: runs::AgentRunRequest,
) -> tinybus::Result<runs::AgentRunHandle> {
+ if request
+ .identity
+ .run_id
+ .as_deref()
+ .is_some_and(|run_id| run_id != self.0.run_id)
+ {
+ return Err(tinybus::Error::failed(
+ "agent request belongs to a different workflow run",
+ ));
+ }
if !valid_agent_request_id(&request.client_request_id) {
return Err(tinybus::Error::failed(
"AgentRun requires a nonempty bounded client_request_id",
diff --git a/crates/openhuman-core/src/flows/caps_host/service_tests.rs b/crates/openhuman-core/src/flows/caps_host/service_tests.rs
index 0abee9fb4f..66a662e36d 100644
--- a/crates/openhuman-core/src/flows/caps_host/service_tests.rs
+++ b/crates/openhuman-core/src/flows/caps_host/service_tests.rs
@@ -86,3 +86,28 @@ fn malformed_agent_request_ids_are_rejected() {
assert!(!valid_agent_request_id(&"x".repeat(129)));
assert!(valid_agent_request_id("client-request-1"));
}
+
+#[tokio::test]
+async fn agent_run_rejects_an_identity_from_another_bound_run() {
+ let temp = tempfile::TempDir::new().unwrap();
+ let binding = super::super::binding_tests::binding(
+ crate::core::runtime::DispatchCtx::unbound(),
+ &temp,
+ );
+ let service = CapsHostService::new(Arc::new(binding));
+ let member = tinybus::MemberName::new(runs::caps::AGENT_RUN).unwrap();
+ let error = tinybus::service::Interface::call(
+ &service,
+ &member,
+ serde_json::json!([{
+ "client_request_id":"request-1",
+ "agent":{"id":"agent"},
+ "identity":{"run_id":"different-run"},
+ "config":{}
+ }]),
+ )
+ .await
+ .unwrap_err();
+
+ assert!(error.to_string().contains("different workflow run"));
+}