Skip to content

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

feat(user_agents): add tool support for user agents

Steven Enamakel7d21adbac1e0
diff --git a/crates/openhuman-core/src/user_agents/tools.rs b/crates/openhuman-core/src/user_agents/tools.rs
index cd46496bd6..cc4503b54d 100644
--- a/crates/openhuman-core/src/user_agents/tools.rs
+++ b/crates/openhuman-core/src/user_agents/tools.rs
@@ -202,7 +202,12 @@ pub fn sandbox_policy_with(
state_dir: &Path,
) -> Result<SandboxPolicy, String> {
let agents = super::layout::agents_dir(saas_root);
- let is_user_sandbox = action_dir.parent().and_then(Path::parent) == Some(agents.as_path())
+ let agent_dir = action_dir.parent();
+ let is_user_sandbox = agent_dir.and_then(Path::parent) == Some(agents.as_path())
+ && agent_dir
+ .and_then(Path::file_name)
+ .and_then(|name| name.to_str())
+ .is_some_and(|name| super::types::UserAgentId::parse(name).is_ok())
&& action_dir.file_name().is_some_and(|name| name == "sandbox");
if !is_user_sandbox {
return Err(format!(
diff --git a/crates/openhuman-core/src/user_agents/tools_tests.rs b/crates/openhuman-core/src/user_agents/tools_tests.rs
index 2170c67415..f3feba3590 100644
--- a/crates/openhuman-core/src/user_agents/tools_tests.rs
+++ b/crates/openhuman-core/src/user_agents/tools_tests.rs
@@ -121,6 +121,8 @@ fn the_sandbox_refuses_anything_but_a_user_sandbox() {
"/srv/oh/agents/sandbox",
"/tmp/sandbox",
"/srv/oh/agents/u-abc/sandbox/nested",
+ "/srv/oh/agents/../sandbox",
+ "/srv/oh/agents/not-an-agent/sandbox",
] {
let dir = PathBuf::from(dir);
assert!(