Skip to content

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

refactor(tinyagents): extract run extension construction into a helper

Steven Enamakel9c85abee62c9
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs
index c484d7a878..e7d2c39db1 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs
@@ -29,6 +29,17 @@ impl std::fmt::Debug for OpenHumanRunExt {
}
}
+impl OpenHumanRunExt {
+ pub(super) fn from_run_context(
+ context: &super::run_context::OpenHumanRunContext,
+ ) -> Self {
+ Self {
+ task_recency_window: context.task_recency_window,
+ command_environment: context.command_environment.clone(),
+ }
+ }
+}
+
/// Reads the explicit command environment from a tool's run context.
pub(crate) fn command_environment_for_tool(
context: Option<&dyn tinytools::ToolRunContext>,
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
index 8463b4c436..ee4aed20df 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
@@ -612,13 +612,8 @@ impl OpenHumanRunContext {
self
}
- /// Builds the explicit child state for a recursive invocation.
- ///
- /// This inheritance rule is tested in B1 and is ready for the later live
- /// plumbing. Cancellation, workspace, progress, policy hooks and dispatch
- /// state are inherited. Route observation and usage accounting are isolated,
- /// so a completed child cannot mutate facts subsequently persisted for its
- /// parent.
+ /// Builds a child context that inherits authority, cancellation and shared
+ /// workspace policy while keeping route observation and usage isolated.
pub fn child(&self) -> Self {
let mut child = self.clone();
child.spawn_depth = self.spawn_depth.saturating_add(1);
@@ -675,10 +670,7 @@ impl OpenHumanRunContext {
}
let cancellation = self.cancellation.clone();
let workspace = self.workspace.clone();
- let run_ext = OpenHumanRunExt {
- task_recency_window: self.task_recency_window,
- command_environment: self.command_environment.clone(),
- };
+ let run_ext = OpenHumanRunExt::from_run_context(&self);
let host_operations = Arc::new(HostOperationContext {
origin: self.origin.clone(),
approval: self.approval.clone(),