The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(user_agents): clear credentials when deprovisioning an agent
Steven Enamakel46fb758167e9
diff --git a/crates/openhuman-core/src/user_agents/credentials_tests.rs b/crates/openhuman-core/src/user_agents/credentials_tests.rsindex 54086994ea..2ce8222cae 100644--- a/crates/openhuman-core/src/user_agents/credentials_tests.rs+++ b/crates/openhuman-core/src/user_agents/credentials_tests.rs@@ -5,8 +5,10 @@ use crate::security::credentials::session_support::{use crate::user_agents::layout::{agent_config, UserAgentLayout};use crate::user_agents::UserAgentId;+/// Credential secrets live in the process keyring keyed by agent id, which+/// every test in this binary shares; each test therefore uses its own users.fn agent(tmp: &tempfile::TempDir, user: &str) -> Config {- let id = UserAgentId::for_user(user).unwrap();+ let id = UserAgentId::for_user(&format!("{user}-{}", uuid::Uuid::new_v4())).unwrap();let layout = UserAgentLayout::new(tmp.path(), &id);std::fs::create_dir_all(&layout.workspace_dir).unwrap();agent_config(&layout, &id)diff --git a/crates/openhuman-core/src/user_agents/host.rs b/crates/openhuman-core/src/user_agents/host.rsindex 010b27f65e..14033312ce 100644--- a/crates/openhuman-core/src/user_agents/host.rs+++ b/crates/openhuman-core/src/user_agents/host.rs@@ -122,6 +122,12 @@ impl AgentHost {if !layout.dir.exists() {return Ok(false);}+ // Credential secrets live in the process keyring under the agent id,+ // not only in the agent's directory, so archiving the directory alone+ // would let a re-provisioned agent pick the old credential back up.+ if let Err(e) = super::credentials::clear(&layout::agent_config(&layout, id)) {+ log::warn!("[user_agents] clearing credentials of agent={id} before archiving: {e}");+ }let archive = layout::archive_dir(&self.saas.root);std::fs::create_dir_all(&archive).map_err(|e| format!("creating {}: {e}", archive.display()))?;diff --git a/crates/openhuman-core/src/user_agents/host_tests.rs b/crates/openhuman-core/src/user_agents/host_tests.rsindex ab37acc505..183ac49454 100644--- a/crates/openhuman-core/src/user_agents/host_tests.rs+++ b/crates/openhuman-core/src/user_agents/host_tests.rs@@ -137,3 +137,26 @@ fn list_reports_provisioned_agents_only() {.collect();assert_eq!(open, vec![&b]);}++#[test]+fn a_reprovisioned_agent_does_not_inherit_the_old_credential() {+ let tmp = tempfile::tempdir().unwrap();+ let host = host(&tmp, 4, 60);+ let id = agent(&format!("returning-{}", uuid::Uuid::new_v4()));+ host.provision(&id).unwrap();+ let config = host.open(&id).unwrap().config.clone();+ super::super::credentials::store(+ &config,+ super::super::credentials::UserCredentialKind::Session,+ "old-session",+ None,+ )+ .unwrap();+ assert!(host.summary(&id).unwrap().unwrap().has_credential);+ host.deprovision(&id).unwrap();+ host.provision(&id).unwrap();+ assert!(+ !host.summary(&id).unwrap().unwrap().has_credential,+ "deprovisioning must forget the credential"+ );+}diff --git a/crates/openhuman-core/src/user_agents/ops_tests.rs b/crates/openhuman-core/src/user_agents/ops_tests.rsindex ecee49b279..4111b9a158 100644--- a/crates/openhuman-core/src/user_agents/ops_tests.rs+++ b/crates/openhuman-core/src/user_agents/ops_tests.rs@@ -45,8 +45,11 @@ fn status_and_deprovision_take_agent_ids_only() {fn credentials_are_set_and_cleared_per_agent_and_never_echoed() {let tmp = tempfile::tempdir().unwrap();let host = host(&tmp);- let alice = UserAgentId::for_user("alice").unwrap();- let bob = UserAgentId::for_user("bob").unwrap();+ // The keyring holding credential secrets is shared by every test here.+ let alice_user = format!("alice-{}", uuid::Uuid::new_v4());+ let bob_user = format!("bob-{}", uuid::Uuid::new_v4());+ let alice = UserAgentId::for_user(&alice_user).unwrap();+ let bob = UserAgentId::for_user(&bob_user).unwrap();assert!(set_credential_on(&host,alice.as_str(),@@ -56,8 +59,8 @@ fn credentials_are_set_and_cleared_per_agent_and_never_echoed() {).unwrap_err().contains("not provisioned"));- provision_on(&host, "alice").unwrap();- provision_on(&host, "bob").unwrap();+ provision_on(&host, &alice_user).unwrap();+ provision_on(&host, &bob_user).unwrap();let out = set_credential_on(&host,