Skip to content

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

feat(session_host): screen user input before assembling the turn graph

Steven Enamakel40e101887b6c
diff --git a/crates/openhuman-core/src/agent/session_host/driver.rs b/crates/openhuman-core/src/agent/session_host/driver.rs
index a3dd6383d7..2f4adedfac 100644
--- a/crates/openhuman-core/src/agent/session_host/driver.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver.rs
@@ -100,6 +100,33 @@ impl SessionDriver<OpenHumanRunContext> for OpenHumanSessionDriver {
.context_middleware
.clone()
.ok_or_else(|| driver_failure("session turn is missing its request-scoped context"))?;
+ let hosted_base = self.hosted_base.clone().ok_or_else(|| {
+ driver_failure(
+ "hosted root invocation is unavailable because the session has no hosted authority",
+ )
+ })?;
+ let security = crate::agent::tinyagents::host::OpenHumanSecurityGate::new(
+ hosted_base.security_policy.clone(),
+ Vec::new(),
+ )
+ .with_input_screening(!request.run_context.data.untrusted_input_turn)
+ .with_approval(request.run_context.data.approval.clone())
+ .with_dispatch(request.run_context.data.dispatch_ctx());
+ let (screened_input, block_reason) = security
+ .screen_new_user_row(&mut request.history)
+ .await
+ .map_err(|error| driver_failure(error.to_string()))?;
+ if let Some(reason) = block_reason {
+ // The generic session persists only a supplied partial on driver
+ // failure. Omitting it prevents a blocked raw input from becoming
+ // durable while preserving the gate's block result.
+ return Err(DriverFailure {
+ error: RuntimeError::Driver(reason),
+ partial: None,
+ outcome: None,
+ });
+ }
+ context_mw.new_input_screened = screened_input;
// The harness drops its `AgentRun` on an error. Snapshot the exact
// request boundary before assembling the graph so the error path can
// persist only provider-accepted rounds, plus a display-only failure
@@ -186,11 +213,7 @@ impl SessionDriver<OpenHumanRunContext> for OpenHumanSessionDriver {
let cancellation = request.run_context.cancellation.clone();
// Boxing avoids worker-stack overflow in debug builds.
let turn = Box::pin(async move {
- let hosted_base = self.hosted_base.clone().ok_or_else(|| {
- anyhow::anyhow!(
- "hosted root invocation is unavailable because the session has no hosted authority"
- )
- })?;
+ let hosted_base = hosted_base.clone();
let mut run_context = run_context;
run_context.workspace = self.workspace.clone().or(run_context.workspace);
run_context.sandbox_mode = Some(self.sandbox_mode);