Skip to content

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

test(cli): assert streaming child prompt before parsing output

Steven Enamakela30e9d144bc7
diff --git a/tests/cli_agent_chat_headless_e2e.rs b/tests/cli_agent_chat_headless_e2e.rs
index 4a2dc659a2..3683bd1465 100644
--- a/tests/cli_agent_chat_headless_e2e.rs
+++ b/tests/cli_agent_chat_headless_e2e.rs
@@ -278,11 +278,18 @@ fn one_shot_cli_waits_for_and_returns_its_spawned_child_result() {
&origin,
&success_logs,
);
+ let probes = primary_llm_probes(&origin);
assert!(
success,
- "one-shot CLI failed; logs: {}\nstdout: {stdout}\nstderr: {stderr}",
+ "one-shot CLI failed; logs: {}\nprobes: {probes:#?}\nstdout: {stdout}\nstderr: {stderr}",
logs.display()
);
+ assert!(
+ probes
+ .iter()
+ .any(|(probe, streaming)| probe.contains(CHILD_PROMPT) && *streaming),
+ "no actual streaming primary LLM request carried the child prompt: {probes:#?}"
+ );
let response: Value = serde_json::from_str(stdout.trim())
.unwrap_or_else(|error| panic!("CLI stdout is not JSON ({error}): {stdout}"));
let result = response["result"]
@@ -301,14 +308,6 @@ fn one_shot_cli_waits_for_and_returns_its_spawned_child_result() {
// llmThreads key for this run. Prove the child request from primary LLM
// request history and the child's unique response from CLI output. Only
// the child rule emits CHILD_RESULT; root completion emits ROOT_RESULT.
- let probes = primary_llm_probes(&origin);
- assert!(
- probes
- .iter()
- .any(|(probe, streaming)| probe.contains(CHILD_PROMPT) && *streaming),
- "no actual streaming primary LLM request carried the child prompt: {probes:#?}"
- );
-
// Repeat with a separate profile and a child model error. A failed
// descendant must make the one-shot CLI fail instead of returning the
// scripted successful root response.