Skip to content

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

docs(subagent): document the test fakes and cases

Shanu8f0466b562ad
diff --git a/src/openhuman/agent/harness/subagent_runner/ops/graph_tests.rs b/src/openhuman/agent/harness/subagent_runner/ops/graph_tests.rs
index 53eb46ca1f..cbcadb68a3 100644
--- a/src/openhuman/agent/harness/subagent_runner/ops/graph_tests.rs
+++ b/src/openhuman/agent/harness/subagent_runner/ops/graph_tests.rs
@@ -452,6 +452,7 @@ async fn cap_hit_summarizes_a_resumable_checkpoint() {
struct WarnSink(Arc<std::sync::Mutex<Vec<String>>>);
impl WarnSink {
+ /// Every captured message containing `marker`, in emission order.
fn matching(&self, marker: &str) -> Vec<String> {
self.0
.lock()
@@ -466,6 +467,7 @@ impl WarnSink {
struct WarnLayer(WarnSink);
impl<S: tracing::Subscriber> tracing_subscriber::Layer<S> for WarnLayer {
+ /// Record the `message` field of every `WARN` event; ignore other levels.
fn on_event(
&self,
event: &tracing::Event<'_>,
@@ -476,6 +478,7 @@ impl<S: tracing::Subscriber> tracing_subscriber::Layer<S> for WarnLayer {
}
struct Message(Option<String>);
impl tracing::field::Visit for Message {
+ /// Keep the formatted `message` field and discard the rest.
fn record_debug(&mut self, field: &tracing::field::Field, value: &dyn std::fmt::Debug) {
if field.name() == "message" {
self.0 = Some(format!("{value:?}"));
@@ -497,15 +500,19 @@ struct SpawnProbeTool(Arc<std::sync::atomic::AtomicBool>);
#[async_trait]
impl Tool for SpawnProbeTool {
+ /// The exact name the #4452 strip must match.
fn name(&self) -> &str {
"spawn_subagent"
}
+ /// Irrelevant to the strip, which reads only the name.
fn description(&self) -> &str {
"spawn a sub-agent"
}
+ /// Irrelevant to the strip, which reads only the name.
fn parameters_schema(&self) -> serde_json::Value {
serde_json::json!({"type": "object"})
}
+ /// Records the dispatch. Reaching this line means the test has failed.
async fn execute(&self, _args: serde_json::Value) -> anyhow::Result<ToolResult> {
self.0.store(true, Ordering::SeqCst);
Ok(ToolResult::success("spawned"))
@@ -519,10 +526,12 @@ struct SpawnAttemptProvider {
#[async_trait]
impl ChatModel<()> for SpawnAttemptProvider {
+ /// Native tool calling, so the harness advertises tools normally.
fn profile(&self) -> Option<&ModelProfile> {
Some(native_tool_profile())
}
+ /// Ask for `spawn_subagent` on the first turn, then finish on the second.
async fn invoke(
&self,
_state: &(),
@@ -590,12 +599,12 @@ async fn run_with_spawn_tool_in_parent_surface(allowed: HashSet<String>) -> (boo
(executed.load(Ordering::SeqCst), sink.matching(REFUSAL))
}
+/// The real shape: `run_typed_mode` has already stripped `spawn_subagent` from
+/// the allowlist, so the registration-time backstop is re-refusing a name that
+/// was never admitted. That is the happy path and must not warn (#6157) — the
+/// old unconditional warn fired here on every sub-agent run.
#[tokio::test]
async fn a_sub_agent_cannot_reach_a_spawn_tool_and_the_healthy_run_is_quiet() {
- // The real shape: `run_typed_mode` has already stripped `spawn_subagent`
- // from the allowlist, so the registration-time backstop is re-refusing a
- // name that was never admitted. That is the happy path and must not warn
- // (#6157) — the old unconditional warn fired here on every sub-agent run.
let allowed = HashSet::from(["echo".to_string()]);
let (executed, warnings) = run_with_spawn_tool_in_parent_surface(allowed).await;
@@ -609,11 +618,11 @@ async fn a_sub_agent_cannot_reach_a_spawn_tool_and_the_healthy_run_is_quiet() {
);
}
+/// The misbuilt-allowlist case the backstop exists for: `spawn_subagent` is
+/// admitted, so registration must still refuse it *and* say so — this is the one
+/// shape in which the warning carries information.
#[tokio::test]
async fn an_allowlist_that_readmits_a_spawn_tool_is_refused_loudly() {
- // The misbuilt-allowlist case the backstop exists for: `spawn_subagent` is
- // admitted, so registration must still refuse it *and* say so — this is the
- // one shape in which the warning carries information.
let allowed = HashSet::from(["echo".to_string(), "spawn_subagent".to_string()]);
let (executed, warnings) = run_with_spawn_tool_in_parent_surface(allowed).await;
diff --git a/src/openhuman/agent/harness/subagent_runner/tool_prep_tests.rs b/src/openhuman/agent/harness/subagent_runner/tool_prep_tests.rs
index 531fdac4f4..31bbb74974 100644
--- a/src/openhuman/agent/harness/subagent_runner/tool_prep_tests.rs
+++ b/src/openhuman/agent/harness/subagent_runner/tool_prep_tests.rs
@@ -346,6 +346,7 @@ impl Tool for NamedTool {
}
}
+/// A dynamic-tool list carrying exactly these names, in this order.
fn dynamic(names: &[&'static str]) -> Vec<Box<dyn Tool>> {
names
.iter()
@@ -353,14 +354,15 @@ fn dynamic(names: &[&'static str]) -> Vec<Box<dyn Tool>> {
.collect()
}
+/// The surviving names, so a test can assert on content *and* order.
fn names_of(tools: &[Box<dyn Tool>]) -> Vec<&str> {
tools.iter().map(|t| t.name()).collect()
}
+/// The shape the runner actually builds: Composio actions plus the
+/// progressive-disclosure handoff tool, with spawn tools interleaved.
#[test]
fn dynamic_tools_keep_ordinary_actions_and_lose_spawn_tools() {
- // The shape the runner actually builds: Composio actions plus the
- // progressive-disclosure handoff tool, with spawn tools interleaved.
let mut tools = dynamic(&[
"GMAIL_FETCH_EMAILS",
"spawn_subagent",
@@ -383,11 +385,11 @@ fn dynamic_tools_keep_ordinary_actions_and_lose_spawn_tools() {
);
}
+/// The whole reason the strip lives here rather than relying on the
+/// registration-time backstop: that backstop matches `delegate_*` by prefix and
+/// would keep `plan`, which is `planner`'s `delegate_name`.
#[test]
fn dynamic_tools_lose_unprefixed_delegate_name_overrides() {
- // The whole reason the strip lives here rather than relying on the
- // registration-time backstop: that backstop matches `delegate_*` by prefix
- // and would keep `plan`, which is `planner`'s `delegate_name`.
let tmp = tempfile::TempDir::new().unwrap();
crate::openhuman::agent::harness::definition::AgentDefinitionRegistry::init_global(tmp.path())
.unwrap();
@@ -402,10 +404,10 @@ fn dynamic_tools_lose_unprefixed_delegate_name_overrides() {
);
}
+/// The live case today: no dynamic tool is named after a spawn tool, so the
+/// strip must be a no-op rather than a silent narrowing of the surface.
#[test]
fn a_dynamic_tool_list_without_spawn_tools_is_untouched() {
- // The live case today: no dynamic tool is named after a spawn tool, so the
- // strip must be a no-op rather than a silent narrowing of the surface.
let mut tools = dynamic(&["GMAIL_FETCH_EMAILS", "extract_from_result"]);
strip_spawn_tools_from_dynamic(&mut tools, "researcher");