Skip to content

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

fix(tests): correct spawn_parallel_agents test to use proper agent ID

Steven Enamakel7cb3f21b2ba0
diff --git a/src/openhuman/agent/orchestration/tools/spawn_parallel_agents_tests.rs b/src/openhuman/agent/orchestration/tools/spawn_parallel_agents_tests.rs
index ccdc85a9d9..0817ef645e 100644
--- a/src/openhuman/agent/orchestration/tools/spawn_parallel_agents_tests.rs
+++ b/src/openhuman/agent/orchestration/tools/spawn_parallel_agents_tests.rs
@@ -1058,11 +1058,22 @@ fn mixed_batch_dispatch_modes_and_claim_conflicts_are_stable() {
ToolScope::Named(vec!["write_fixture".into()]),
SandboxMode::None,
);
+ // Defined but deliberately omitted from the parent allowlist below, so it
+ // is policy-rejected *before* any claim is admitted. An earlier rejection
+ // must not advance `admitted_index`, or every later admitted task would
+ // resolve to the wrong plan slot and the clasher's conflict would be
+ // misattributed — this batch pins that the index stays admission-scoped.
+ let outside = definition_with_tool_scope(
+ "outside",
+ ToolScope::Named(vec!["write_fixture".into()]),
+ SandboxMode::None,
+ );
let definitions = HashMap::from([
(isolated_writer.id.clone(), isolated_writer),
(reader.id.clone(), reader),
(writer.id.clone(), writer),
(clasher.id.clone(), clasher),
+ (outside.id.clone(), outside),
]);
let parent = parent_admitting(
&["isolated_writer", "reader", "writer", "clasher"],
@@ -1071,6 +1082,7 @@ fn mixed_batch_dispatch_modes_and_claim_conflicts_are_stable() {
let preflight = prepare_spawn_parallel_tasks_from_defs(
vec![
+ dispatch_task("outside", None, None),
dispatch_task("isolated_writer", None, Some("worktree")),
dispatch_task("reader", None, None),
dispatch_task("writer", Some("files: src/a.rs"), None),
@@ -1080,6 +1092,18 @@ fn mixed_batch_dispatch_modes_and_claim_conflicts_are_stable() {
&parent,
);
+ // The earlier policy rejection is surfaced in place, without advancing the
+ // admission index the later dispatch decisions key off.
+ match &preflight[0] {
+ SpawnParallelTaskPreflight::Rejected(rejection) => {
+ assert_eq!(rejection.kind, ParallelTaskRejectionKind::OutsideAllowlist);
+ assert_eq!(rejection.agent_id, "outside");
+ }
+ SpawnParallelTaskPreflight::Prepared(_) => {
+ panic!("an agent outside the allowlist must be rejected")
+ }
+ }
+
let modes: Vec<Option<WorkerDispatchMode>> = preflight
.iter()
.map(|entry| match entry {
@@ -1091,16 +1115,19 @@ fn mixed_batch_dispatch_modes_and_claim_conflicts_are_stable() {
assert_eq!(
modes,
vec![
+ None,
Some(WorkerDispatchMode::Parallel),
Some(WorkerDispatchMode::Parallel),
Some(WorkerDispatchMode::SerialSharedWorkspaceWrite),
None,
],
- "write-safety dispatch decision changed"
+ "write-safety dispatch decision changed after an earlier rejection"
);
// The rejection is the *later* claimant; the earlier one keeps its claim.
- match &preflight[3] {
+ // Index 4 (not 3) because the leading `outside` rejection did not consume
+ // an admission slot.
+ match &preflight[4] {
SpawnParallelTaskPreflight::Rejected(rejection) => {
assert_eq!(rejection.kind, ParallelTaskRejectionKind::RequiresIsolation);
assert_eq!(rejection.agent_id, "clasher");