Skip to content

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

test(runner-checkpoint): add test for legacy checkpoint with toolkit override and fix e2e test to id

Steven Enamakel89d83cb333c9
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner_checkpoint_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner_checkpoint_tests.rs
index d0a3c8f18c..cb8a6209c9 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner_checkpoint_tests.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner_checkpoint_tests.rs
@@ -158,3 +158,18 @@ fn the_ids_this_system_actually_mints_are_accepted() {
);
}
}
+
+#[test]
+fn a_legacy_checkpoint_with_toolkit_override_still_parses() {
+ // Checkpoints written before the `toolkit` spawn argument was retired
+ // carry a `toolkit_override` key. Resume must still read them.
+ let mut value = serde_json::to_value(checkpoint_data("task-legacy")).expect("serialise");
+ value
+ .as_object_mut()
+ .expect("checkpoint is an object")
+ .insert("toolkit_override".into(), serde_json::json!("gmail"));
+ let parsed: SubagentCheckpointData =
+ serde_json::from_value(value).expect("legacy checkpoint parses");
+ assert_eq!(parsed.task_id, "task-legacy");
+ assert_eq!(parsed.question, "Which region?");
+}
diff --git a/tests/agent_harness_e2e.rs b/tests/agent_harness_e2e.rs
index 62731c7b86..1a11f2be25 100644
--- a/tests/agent_harness_e2e.rs
+++ b/tests/agent_harness_e2e.rs
@@ -3521,6 +3521,52 @@ fn advertised_tool_names(request: &Value) -> Vec<String> {
schema_names.chain(prompt_names).collect()
}
+/// Heading of the orchestrator's own `prompt.md`; picks its requests out of a
+/// turn that also carries a specialist's.
+#[cfg(feature = "skills")]
+const ORCHESTRATOR_PROMPT_MARKER: &str = "## How you work";
+
+/// Concatenated system-message text of one captured model request.
+#[cfg(feature = "skills")]
+fn system_prompt_text(request: &Value) -> String {
+ request
+ .pointer("/body/messages")
+ .and_then(Value::as_array)
+ .into_iter()
+ .flatten()
+ .filter(|message| message.get("role").and_then(Value::as_str) == Some("system"))
+ .filter_map(|message| message.get("content"))
+ .map(|content| {
+ content
+ .as_str()
+ .map(str::to_string)
+ .unwrap_or_else(|| content.to_string())
+ })
+ .collect::<Vec<_>>()
+ .join("\n")
+}
+
+/// Whether the request's `use_skill` declaration lists `pack` among its skills.
+/// Native providers carry it in the `tools` schema (the `skill` enum); text
+/// dialects render the catalogue into the system prompt.
+#[cfg(feature = "skills")]
+fn use_skill_offers_pack(request: &Value, pack: &str) -> bool {
+ let quoted = format!("\"{pack}\"");
+ let in_schema = request
+ .pointer("/body/tools")
+ .and_then(Value::as_array)
+ .into_iter()
+ .flatten()
+ .filter(|tool| {
+ tool.pointer("/function/name")
+ .or_else(|| tool.get("name"))
+ .and_then(Value::as_str)
+ == Some("use_skill")
+ })
+ .any(|tool| tool.to_string().contains(&quoted));
+ in_schema || system_prompt_text(request).contains(pack)
+}
+
/// One scripted turn in which the orchestrator hands a request to a specialist
/// by calling `hand_off` directly.
///
@@ -3633,12 +3679,30 @@ async fn orchestrator_hands_skill_installs_to_skill_setup_directly_inner() {
],
)
.await;
- // Same turn's requests: the orchestrator runs skills itself.
+ // Same turn's requests: the orchestrator runs skills itself. Read ITS
+ // request (identified by its own prompt heading), not whichever request
+ // happened to be captured first.
let requests = with_captured(|c| c.clone());
- let belt = advertised_tool_names(requests.first().expect("orchestrator model request"));
+ let orchestrator = requests
+ .iter()
+ .find(|request| system_prompt_text(request).contains(ORCHESTRATOR_PROMPT_MARKER))
+ .unwrap_or_else(|| {
+ panic!(
+ "no captured request carried the orchestrator prompt ({ORCHESTRATOR_PROMPT_MARKER:?}); \
+ requests: {}",
+ serde_json::to_string_pretty(&requests).unwrap_or_default()
+ )
+ });
+ let belt = advertised_tool_names(orchestrator);
+ // `run_workflow` is a member of the `workflows` tool pack, so it is
+ // reachable either directly or through `use_skill` with that pack.
+ let direct = belt.iter().any(|name| name == "run_workflow");
+ let via_pack = belt.iter().any(|name| name == "use_skill")
+ && use_skill_offers_pack(orchestrator, "workflows");
assert!(
- belt.iter().any(|name| name == "run_workflow"),
- "the orchestrator must advertise `run_workflow` directly; it advertised {belt:?}"
+ direct || via_pack,
+ "the orchestrator must reach `run_workflow` (directly or via use_skill `workflows`); \
+ it advertised {belt:?}"
);
assert!(
!belt.iter().any(|name| name == "run_skill"),