Skip to content

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

feat(tinyagents): add headless descendant settlement control to security gate

Steven Enamakel62669019ea26
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs b/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs
index 693c8cb191..2a470ccc86 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs
@@ -161,7 +161,8 @@ impl OpenHumanHostBundleFactory {
let mut security = OpenHumanSecurityGate::new(inputs.security_policy, inputs.tool_sets)
.with_input_screening(!turn.untrusted_input_turn)
.with_approval(turn.approval.clone())
- .with_dispatch(turn.dispatch_ctx());
+ .with_dispatch(turn.dispatch_ctx())
+ .with_headless_descendant_settlement(turn.headless_descendant_settlement);
if let Some(policy) = inputs.tool_policy {
security = security.with_tool_policy(policy);
}
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs
index 56fc671c5b..687f2e4dc7 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs
@@ -151,6 +151,10 @@ pub struct OpenHumanSecurityGate {
/// The owning turn's dispatch context, read from the turn's run context
/// when the gate is built; `None` falls back to the calling task's.
dispatch: Option<std::sync::Weak<crate::core::runtime::CoreContext>>,
+ /// Only a root that owns settlement of its headless child tree may use
+ /// recursive delegation as orchestration control under the Cron policy.
+ /// The Cron origin check remains mandatory at authorization time.
+ headless_descendant_settlement: bool,
}
impl OpenHumanSecurityGate {
@@ -170,9 +174,16 @@ impl OpenHumanSecurityGate {
screens_input: true,
approval: ApprovalTurnContext::default(),
dispatch: None,
+ headless_descendant_settlement: false,
}
}
+ /// Marks the gate as part of a host-owned headless root turn.
+ pub(crate) fn with_headless_descendant_settlement(mut self, enabled: bool) -> Self {
+ self.headless_descendant_settlement = enabled;
+ self
+ }
+
/// Binds the owning turn's dispatch context.
pub fn with_dispatch(mut self, dispatch: DispatchCtx) -> Self {
self.dispatch = dispatch.downgrade();
@@ -529,7 +540,7 @@ impl OpenHumanSecurityGate {
// actions. Keep cron agent turns within a read-only tool capability.
// This check precedes the shell shortcut and all approval settings,
// including installations where the approval gate is disabled.
- if matches!(
+ let is_cron_turn = matches!(
self.turn_origin(),
Some(
crate::security::turn_origin::AgentTurnOrigin::TrustedAutomation {
@@ -537,10 +548,15 @@ impl OpenHumanSecurityGate {
..
}
)
- ) && (call.tool_name == SHELL_TOOL
- || tool.permission_level_with_args(&call.arguments) > PermissionLevel::ReadOnly
- || tool.external_effect_with_args(&call.arguments))
- {
+ );
+ let is_headless_spawn_control = self.headless_descendant_settlement
+ && call.tool_name == "spawn_subagent";
+ let is_cron_denial = is_cron_turn
+ && (call.tool_name == SHELL_TOOL
+ || tool.external_effect_with_args(&call.arguments)
+ || (tool.permission_level_with_args(&call.arguments) > PermissionLevel::ReadOnly
+ && !is_headless_spawn_control));
+ if is_cron_denial {
return Ok(GateDecision::deny(format!(
"{} Scheduled agent turns may use read-only tools only; '{}' needs a live user action.",
tinytools::status::POLICY_DENIED_MARKER,