Skip to content

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

test(tokenjuice): require every mention of re-running to be the negated one

yh928b2801eee73dd
diff --git a/src/openhuman/inference/tokenjuice/tools_tests.rs b/src/openhuman/inference/tokenjuice/tools_tests.rs
index 1276d9b5dc..9980b18567 100644
--- a/src/openhuman/inference/tokenjuice/tools_tests.rs
+++ b/src/openhuman/inference/tokenjuice/tools_tests.rs
@@ -41,11 +41,23 @@ fn miss_message_does_not_instruct_a_blind_re_run() {
// See `miss_message` — "re-run the tool" here is what turned a single
// eviction into an unbounded compact→retrieve→re-run loop.
let msg = miss_message("deadbeefcafe").to_lowercase();
- assert!(!msg.contains("re-run the same tool") || msg.contains("do not re-run"));
assert!(
msg.contains("do not re-run"),
"must discourage re-running: {msg}"
);
+ // And must not also say the opposite. The loop this fixes came from an
+ // affirmative instruction, so a message carrying both would read as
+ // permission to re-run while the assertion above still passed. Every
+ // mention of re-running has to be the negated one.
+ let mut cursor = 0;
+ while let Some(found) = msg[cursor..].find("re-run") {
+ let at = cursor + found;
+ assert!(
+ msg[..at].trim_end().ends_with("do not"),
+ "every mention of re-running must be negated, found a bare one at {at}: {msg}"
+ );
+ cursor = at + "re-run".len();
+ }
assert!(
msg.contains("compacted summary"),
"must point at the summary: {msg}"