Skip to content

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

refactor(session_host): defer hosted authority check into turn

Steven Enamakela43e4e7c6e8c
diff --git a/crates/openhuman-core/src/agent/session_host/driver.rs b/crates/openhuman-core/src/agent/session_host/driver.rs
index 2f4adedfac..a3dd6383d7 100644
--- a/crates/openhuman-core/src/agent/session_host/driver.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver.rs
@@ -100,33 +100,6 @@ 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
@@ -213,7 +186,11 @@ 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 = hosted_base.clone();
+ 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 mut run_context = run_context;
run_context.workspace = self.workspace.clone().or(run_context.workspace);
run_context.sandbox_mode = Some(self.sandbox_mode);