diff --git a/xtask/src/scenario_eval.rs b/xtask/src/scenario_eval.rs index 43a358479..f9d3eed41 100644 --- a/xtask/src/scenario_eval.rs +++ b/xtask/src/scenario_eval.rs @@ -16760,6 +16760,39 @@ mod tests { path } + /// What a run's export says about its own compaction and input estimate: + /// the fact the request markers cannot tell apart from a lost prompt. + fn compaction_evidence(out: &Path, arm: &str) -> String { + let path = out + .join("outputs") + .join(arm) + .join("case") + .join("run-0.timeline.jsonl"); + let (mut statuses, mut estimates) = (Vec::new(), Vec::new()); + if let Ok(export) = std::fs::read_to_string(&path) { + for line in export.lines() { + let Ok(value) = serde_json::from_str::(line) else { + continue; + }; + let event = &value["event"]; + match (event["type"].as_str(), event["name"].as_str()) { + (Some("context"), Some("compaction")) => statuses.push(format!( + "{} {}", + event["data"]["status"].as_str().unwrap_or("-"), + event["data"]["strategy"].as_str().unwrap_or("-") + )), + (Some("context"), Some("budget")) => estimates.push( + event["data"]["estimatedInputTokens"] + .as_f64() + .unwrap_or_default(), + ), + _ => {} + } + } + } + format!("compactions={statuses:?} estimates={estimates:?}") + } + /// Both arms run the shipped assembly on the same scenario, and the /// candidate text reaches the candidate arm's summarizer request and only /// that arm's. The judge is the wide one: the run's message makes its view @@ -16837,11 +16870,33 @@ mod tests { } let current = fixture.arm("current"); let candidate = fixture.arm("candidate"); + // A current arm without a summarizer request means compaction did not + // run, not that the product prompt went missing; the failure states + // which requests each arm recorded. + let mut diagnosis = String::new(); + for record in &records { + diagnosis.push_str(&format!("\nrecord {record}")); + } + for (arm, requests) in [("current", ¤t), ("candidate", &candidate)] { + diagnosis.push_str(&format!( + "\n{arm}: {} requests {}", + requests.len(), + compaction_evidence(&options.out, arm) + )); + for request in requests.iter() { + diagnosis.push_str(&format!( + "\n summarizer={} candidate={} bytes={}", + request.contains("You summarize a coding session"), + request.contains("CANDIDATE SUMMARY PROMPT"), + request.len() + )); + } + } assert!( current .iter() .any(|request| request.contains("You summarize a coding session")), - "the current arm's summarizer request carries the product prompt" + "the current arm's summarizer request carries the product prompt: {diagnosis}" ); assert!( current @@ -16853,7 +16908,7 @@ mod tests { candidate .iter() .any(|request| request.contains("CANDIDATE SUMMARY PROMPT")), - "the candidate arm's summarizer request carries the candidate text" + "the candidate arm's summarizer request carries the candidate text: {diagnosis}" ); assert!( candidate