The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(subagent_host): simplify workspace descriptor handling
Steven Enamakel57a65c8dbf1a
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rsindex 4a0929e528..882760eb26 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs@@ -282,28 +282,9 @@ pub(crate) async fn run_subagent_direct_with_native_context(// The child carrier projects the definition's sandbox mode to every// tool through HostOperationContext.//- // When the worker opted into git-worktree isolation, its isolated- // checkout is carried on the `WorkspaceDescriptor` prepared below and- // threaded onto the run's tinyagents `RunContext`- // (`TurnSpec::run` → `RunContext::with_workspace`).- // Every tool call then receives it via- // `ToolExecutionContext::from_run_context`, so acting tools (shell, git)- // resolve their CWD to that worktree (`effective_action_dir_for_context`)- // instead of the shared `Config.action_dir` — no task-local override- // needed. When no descriptor is prepared (the default / non-isolated- // path), tools fall through to `security.action_dir` and behaviour is- // unchanged.let mut parent_for_subagent = parent.clone();- parent_for_subagent.workspace_descriptor =- workspace_descriptor_for_subagent(definition, &options, &parent, &task_id);- if let Some(descriptor) = parent_for_subagent.workspace_descriptor.as_ref() {- tracing::debug!(- agent_id = %definition.id,- task_id = %task_id,- worktree = %descriptor.root.display(),- policy_id = %descriptor.policy_id,- "[subagent_host] worktree-isolated worker: descriptor will route acting-tool CWD"- );+ if options.workspace_descriptor.is_some() {+ parent_for_subagent.workspace_descriptor = options.workspace_descriptor.clone();}let run_result = Box::pin(with_run_depth(RunDepth { depth: attempted_depth, max_depth }, async {with_file_state_agent_id(task_id.clone(), async {@@ -384,30 +365,6 @@ pub(crate) async fn run_subagent_direct_with_native_context(.await}-fn workspace_descriptor_for_subagent(- definition: &AgentDefinition,- options: &SubagentRunOptions,- parent: &ParentExecutionContext,- task_id: &str,-) -> Option<WorkspaceDescriptor> {- if let Some(descriptor) = options.workspace_descriptor.clone() {- return Some(descriptor);- }- if let Some(descriptor) = parent.workspace_descriptor.clone() {- return Some(descriptor);- }- let root = options.worktree_action_dir.clone()?;- let sandbox = match definition.sandbox_mode {- AgentSandboxMode::Sandboxed => TinyagentsSandboxMode::Required,- AgentSandboxMode::None | AgentSandboxMode::ReadOnly => TinyagentsSandboxMode::Inherit,- };- Some(- WorkspaceDescriptor::new(root)- .with_policy_id(format!("openhuman.worktree:{task_id}"))- .with_sandbox(sandbox),- )-}-/// One spawn's snapshot of the host config, loaded once by [`run_subagent`].////// `Config::load_or_init()` is **not cached** — it re-resolves the config dirs@@ -613,15 +570,11 @@ async fn run_typed_mode(subagent_prompt_protocol(parent.tool_call_format, &filtered_specs);// Load AGENTS.md instruction layers once, at prompt-build time, when the// config gate is on. The global layer comes from the workspace dir; the- // project layer comes from the sub-agent's `worktree_action_dir` override- // when present (git-worktree isolation), otherwise the global config- // `action_dir`. Loading here (not per turn) keeps the sub-agent system+ // project layer comes from the global config `action_dir`. Loading here+ // (not per turn) keeps the sub-agent system// prompt byte-stable for prefix caching.let agents_md = if parent.agent_config.agents_md_enabled {- let local_dir = options- .worktree_action_dir- .clone()- .or_else(|| config.as_ref().ok().map(|c| c.action_dir.clone()));+ let local_dir = config.as_ref().ok().map(|c| c.action_dir.clone());match local_dir {Some(dir) => crate::agent::prompts::load_agents_md_layers(&parent.workspace_dir, &dir),None => {diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner_artifacts.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner_artifacts.rsindex b9cbf0169e..8bd7094d32 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner_artifacts.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner_artifacts.rs@@ -29,14 +29,10 @@ pub(super) async fn apply_subagent_result_policies(let mut paths = extract_artifact_paths(&outcome.output);let mut artifact_error = None;- // Preserve an explicit worktree root as the action-dir fallback. With a- // live policy, the guarded writer materializes under that policy's action+ // With a live policy, the guarded writer materializes under that policy's action// root so the parent can resolve the returned relative path.let policy = crate::security::live_policy::effective_in(&options.run_context.dispatch_ctx());- let action_dir = options- .worktree_action_dir- .clone()- .or_else(|| policy.as_ref().map(|p| p.action_dir.clone()));+ let action_dir = policy.as_ref().map(|p| p.action_dir.clone());let can_store = !policy.as_ref()diff --git a/crates/openhuman-core/src/agent/subagent_host/types.rs b/crates/openhuman-core/src/agent/subagent_host/types.rsindex 95d8c3c2e5..b2e89c2c99 100644--- a/crates/openhuman-core/src/agent/subagent_host/types.rs+++ b/crates/openhuman-core/src/agent/subagent_host/types.rs@@ -59,17 +59,6 @@ pub struct SubagentRunOptions {/// `{workspace_dir}/.openhuman/subagent_checkpoints/`.pub checkpoint_dir: Option<PathBuf>,- /// Per-worker isolated checkout for git-worktree isolation.- ///- /// When `Some`, the runner derives a [`WorkspaceDescriptor`] rooted at this- /// path (see `workspace_descriptor_for_subagent`) and threads it onto the- /// tinyagents run context, so acting tools (shell, git) resolve their CWD to- /// the worker's isolated worktree checkout via- /// `ToolExecutionContext.workspace` instead of the shared `Config.action_dir`.- /// When `None` (the default), behaviour is unchanged — tools fall through to- /// `security.action_dir`.- pub worktree_action_dir: Option<PathBuf>,-/// SDK workspace descriptor threaded into the TinyAgents tool-execution/// context. When present it is attached to the run's `RunContext`/// (`RunContext::with_workspace`) and surfaced per tool call via