Skip to content

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

Merge upstream/main into bench-6951-truncated-reasoning

Steven Enamakel29db0e8d5c9b
diff --cc crates/openhuman-core/src/agent/session_host/turn_checkpoint_tests.rs
index ae17eb6871,9387cdbc14..1f9f21d629
--- a/crates/openhuman-core/src/agent/session_host/turn_checkpoint_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/turn_checkpoint_tests.rs
@@@ -442,42 -441,51 +442,91 @@@ fn the_repair_re_ask_names_the_violatio
assert!(empty.contains("empty or tried to call a tool"), "{empty}");
}
+/// #6951: a turn whose last reply ran out of output tokens while reasoning
+/// did not "finish using tools". The close must say what actually happened so
+/// the model reports unfinished work honestly instead of a tidy summary.
+#[test]
+fn a_truncated_close_names_the_output_budget_instead_of_finished_tools() {
+ let records = "\n- `read_file` — ok\n > config found\n";
+ let out = final_answer_instruction(None, true, records);
+ assert!(out.contains("ran out of output tokens"), "{out}");
+ assert!(!out.contains("You have finished using tools"), "{out}");
+ assert!(out.contains("do not call any tools"), "{out}");
+ assert!(out.contains(" > config found"), "{out}");
+
+ let plain = final_answer_instruction(None, false, records);
+ assert!(plain.contains("You have finished using tools"), "{plain}");
+ assert!(!plain.contains("ran out of output tokens"), "{plain}");
+}
+
+/// A breaker halt explains the stop more precisely than truncation does, so
+/// its stop note still leads when both apply.
+#[test]
+fn a_breaker_halt_keeps_its_stop_note_on_a_truncated_turn() {
+ let out = final_answer_instruction(Some(STOP_NOTE), true, "");
+ assert!(out.contains("<stop_note>"), "{out}");
+}
+
+/// The truncated wording is harness text too: a reply quoting it is caught.
+#[test]
+fn quoting_the_truncated_close_instruction_is_caught() {
+ let out = final_answer_instruction(None, true, "");
+ let lead = out
+ .lines()
+ .nth(1)
+ .and_then(|line| line.split('.').next())
+ .expect("the directive opens with a sentence");
+ assert!(
+ quotes_harness_instruction(&format!("{lead}. Here is my summary."), None),
+ "lead span should be a needle: {lead}"
+ );
+}
++
+ /// #6958: at the 200-call cap a DeepSWE run with no source edits answered this
+ /// round by writing `ROLLING_WINDOW_IMPLEMENTATION_NOTES.md` into the user's
+ /// repo, because the instruction said an incomplete file "is worth far more
+ /// than no file at all". For a code change the deliverable is the edits, so
+ /// the round must steer at `apply_patch`/`file_write` on source files and
+ /// forbid notes or plan files in the project.
+ #[test]
+ fn the_final_write_instruction_steers_code_tasks_to_real_edits() {
+ let text = FINAL_WRITE_INSTRUCTION;
+ let lower = text.to_lowercase();
+ assert!(
+ text.contains("apply_patch") && text.contains("file_write"),
+ "names the tools that make the edits: {text}"
+ );
+ assert!(
+ lower.contains("source files"),
+ "a code task's deliverable is its source edits: {text}"
+ );
+ for forbidden in ["notes", "plan", "summary"] {
+ assert!(
+ lower.contains(forbidden),
+ "must explicitly rule out a `{forbidden}` file in the project: {text}"
+ );
+ }
+ assert!(
+ lower.contains("partial set of real edits"),
+ "a partial change beats a document about it: {text}"
+ );
+ assert!(
+ !lower.contains("incomplete file") && !lower.contains("worth far more than no file"),
+ "the wording that produced the notes file must be gone: {text}"
+ );
+ }
+
+ /// The round still exists for the case it was built for (#6548): a task whose
+ /// requested product *is* a file must still be told to write it.
+ #[test]
+ fn the_final_write_instruction_still_asks_for_a_requested_file() {
+ let lower = FINAL_WRITE_INSTRUCTION.to_lowercase();
+ assert!(
+ lower.contains("asked you to produce a file"),
+ "{FINAL_WRITE_INSTRUCTION}"
+ );
+ assert!(
+ lower.contains("do not call a tool"),
+ "nothing to write still means answer instead: {FINAL_WRITE_INSTRUCTION}"
+ );
+ }