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\n\nThe miss-message assertion passed on a message that both forbade and\ninstructed a re-run: `contains("do not re-run")` is satisfied while a bare\n"re-run the tool" sits elsewhere in the same string, which reads to the\nmodel as permission and is exactly the loop this fixes.\n\nScan the message instead — every occurrence of "re-run" must be preceded\nby "do not".\n\nThe `ccr_disk_enabled` default flip that used to ride along in this commit\nis split out (see the PR discussion): it is a data-at-rest product decision\nand does not belong in a loop fix.\n

yh92832e7bda7968d
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}"