Skip to content

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

refactor(subagent_host): tidy imports and formatting

Steven Enamakela8968ff65207
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
index 8c3443a6c1..a586944861 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
@@ -572,15 +572,18 @@ pub struct OpenHumanSubagentHost {
/// Shared TinyAgents reservations are partitioned by the canonical checkpoint
/// root because product task IDs can repeat across workspaces.
-type ScopedSubagentFlights =
- std::sync::Mutex<std::collections::HashMap<PathBuf, tinyagents_orchestration::subagent::SubagentInFlight>>;
+type ScopedSubagentFlights = std::sync::Mutex<
+ std::collections::HashMap<PathBuf, tinyagents_orchestration::subagent::SubagentInFlight>,
+>;
pub(super) fn shared_subagent_flight(
ctx: &crate::core::runtime::DispatchCtx,
checkpoint_dir: &std::path::Path,
) -> tinyagents_orchestration::subagent::SubagentInFlight {
let flights = crate::core::runtime::slot_for::<ScopedSubagentFlights>(ctx);
- let mut flights = flights.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
+ let mut flights = flights
+ .lock()
+ .unwrap_or_else(|poisoned| poisoned.into_inner());
flights
.entry(checkpoint_dir.to_path_buf())
.or_default()
@@ -615,11 +618,19 @@ impl OpenHumanSubagentHost {
child_config,
)
.map_err(|error| SubagentRunError::Provider(anyhow::anyhow!(error.to_string())))?;
- let checkpoint_dir = absolute_checkpoint_dir(self.options.checkpoint_dir.clone().unwrap_or_else(|| {
- parent.data.parent.as_ref().map(|context| {
- context.workspace_dir.join(".openhuman/subagent_checkpoints")
- }).unwrap_or_else(|| PathBuf::from(".openhuman/subagent_checkpoints"))
- }));
+ let checkpoint_dir =
+ absolute_checkpoint_dir(self.options.checkpoint_dir.clone().unwrap_or_else(|| {
+ parent
+ .data
+ .parent
+ .as_ref()
+ .map(|context| {
+ context
+ .workspace_dir
+ .join(".openhuman/subagent_checkpoints")
+ })
+ .unwrap_or_else(|| PathBuf::from(".openhuman/subagent_checkpoints"))
+ }));
Box::pin(self.run_leader(parent, task_key, child, input, false, checkpoint_dir)).await
}
@@ -636,11 +647,19 @@ impl OpenHumanSubagentHost {
child_config,
)
.map_err(|error| SubagentRunError::Provider(anyhow::anyhow!(error.to_string())))?;
- let checkpoint_dir = absolute_checkpoint_dir(self.options.checkpoint_dir.clone().unwrap_or_else(|| {
- parent.data.parent.as_ref().map(|context| {
- context.workspace_dir.join(".openhuman/subagent_checkpoints")
- }).unwrap_or_else(|| PathBuf::from(".openhuman/subagent_checkpoints"))
- }));
+ let checkpoint_dir =
+ absolute_checkpoint_dir(self.options.checkpoint_dir.clone().unwrap_or_else(|| {
+ parent
+ .data
+ .parent
+ .as_ref()
+ .map(|context| {
+ context
+ .workspace_dir
+ .join(".openhuman/subagent_checkpoints")
+ })
+ .unwrap_or_else(|| PathBuf::from(".openhuman/subagent_checkpoints"))
+ }));
Box::pin(self.run_leader(parent, task_key, child, input, true, checkpoint_dir)).await
}
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs b/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs
index 875276fcf3..fc7c333447 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs
@@ -3,9 +3,9 @@
use crate::inference::provider::BilledUsage;
use std::sync::{Arc, Mutex};
use tinyagents_harness::summarization::CapToolResult;
+use tinyagents_orchestration::subagent::{summarize_at_cap, CapSummaryModel};
use tinyinference_llm::message::Message;
use tinyinference_llm::model::{ChatModel, ModelRequest};
-use tinyagents_orchestration::subagent::{CapSummaryModel, summarize_at_cap};
/// The provider usage from a summary call, charged by the host after the owner
/// API applies its shared digest and fallback policy.
@@ -58,8 +58,8 @@ impl CapSummaryModel for HostCapSummaryModel<'_> {
accomplished, what still remains) for the agent that delegated to you. Do not call tools.\n\n{digest}",
self.checkpoint.agent_id,
))];
- let request = ModelRequest::new(summary_input)
- .with_max_tokens(self.checkpoint.max_output_tokens);
+ let request =
+ ModelRequest::new(summary_input).with_max_tokens(self.checkpoint.max_output_tokens);
match self.checkpoint.chat_model.invoke(&(), request).await {
Ok(response) => {
let usage = crate::inference::provider::model::usage_info_from_response(&response);
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/prompt.rs b/crates/openhuman-core/src/agent/subagent_host/ops/prompt.rs
index c051c6786b..4711150e0d 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/prompt.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/prompt.rs
@@ -98,7 +98,3 @@ pub(super) fn dedup_tool_specs_by_name(agent_id: &str, specs: Vec<ToolSpec>) ->
}
deduped
}
-
-#[cfg(test)]
-#[path = "prompt_tests.rs"]
-mod tests;
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/prompt_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops/prompt_tests.rs
deleted file mode 100644
index 4563e55b7b..0000000000
--- a/crates/openhuman-core/src/agent/subagent_host/ops/prompt_tests.rs
+++ /dev/null
@@ -1 +0,0 @@
-use super::*;
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
index 98a65b9b3e..b10f03c683 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
@@ -27,18 +27,16 @@ use tinyagents_definition::{
validate_tier_transition, AgentTier, IterationPolicy, PromptSource,
SandboxMode as AgentSandboxMode,
};
-use tinyagents_orchestration::subagent::{subagent_framing, SubagentRole};
use tinyagents_harness::artifacts::{
effective_offload_threshold, extract_artifact_paths, note_artifact_handoff,
DEFAULT_OFFLOAD_THRESHOLD_BYTES, HANDOFF_STAGE_RECORDED,
};
use tinyagents_harness::context::{current_run_depth, with_run_depth, RunConfig, RunDepth};
+use tinyagents_orchestration::subagent::{subagent_framing, SubagentRole};
use tinytools::{SandboxMode as TinyagentsSandboxMode, ToolSpec, WorkspaceDescriptor};
use tinytools_std::file_state::with_file_state_agent_id;
-use super::prompt::{
- append_artifact_offload_contract, dedup_tool_specs_by_name,
-};
+use super::prompt::{append_artifact_offload_contract, dedup_tool_specs_by_name};
use super::provider::resolve_subagent_source;
/// Runtime spawn-hierarchy gate decision for one delegation hop.
@@ -803,7 +801,11 @@ async fn run_typed_mode(
}
};
- let framing = subagent_framing(SubagentRole::Leaf, options.run_context.spawn_depth, task_prompt);
+ let framing = subagent_framing(
+ SubagentRole::Leaf,
+ options.run_context.spawn_depth,
+ task_prompt,
+ );
let system_prompt = format!("{}\n\n{framing}", system_prompt.trim_end());
// #3883: only agents that actually hold a file-write tool are told to
// offload. `visible_tool_names` is this sub-agent's real, post-filter tool