The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(agent): restore turn outcome checkpointing
Steven Enamakel38a7d04dd385
diff --git a/crates/openhuman-core/src/agent/session_host/turn_checkpoint_tests.rs b/crates/openhuman-core/src/agent/session_host/turn_checkpoint_tests.rsindex e790696948..f02a3e730e 100644--- a/crates/openhuman-core/src/agent/session_host/turn_checkpoint_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/turn_checkpoint_tests.rs@@ -440,3 +440,43 @@ fn the_repair_re_ask_names_the_violation_and_repeats_the_instruction() {let empty = close_repair_instruction(&instruction, CloseViolation::NoReply);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}"+ );+}diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_outcome.rs b/crates/openhuman-core/src/agent/tinyagents/turn_outcome.rsindex b8e0e3f576..2d5db57247 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_outcome.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_outcome.rs@@ -80,6 +80,15 @@ pub(crate) struct TinyagentsTurnOutcome {pub tool_outcomes: Vec<ToolCallOutcome>,}+/// Whether a run's final response is a reply that ran out of output tokens+/// before producing anything: `finish_reason = length`, no visible text and no+/// tool call. See [`TinyagentsTurnOutcome::truncated`].+pub(crate) fn ended_out_of_output_budget(+ _final_response: Option<&tinyinference_llm::model::ModelResponse>,+) -> bool {+ false+}+/// One tool call's execution outcome, captured at the tool boundary before the/// harness discards the failure flag. `success` mirrors the absence of a/// `TaToolResult::error`; `content` is the (possibly summarized/capped) result@@ -148,3 +157,7 @@ pub(crate) fn record_unobserved_turn_usage();true}++#[cfg(test)]+#[path = "turn_outcome_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_outcome_tests.rs b/crates/openhuman-core/src/agent/tinyagents/turn_outcome_tests.rsnew file mode 100644index 0000000000..f69e4dfb14--- /dev/null+++ b/crates/openhuman-core/src/agent/tinyagents/turn_outcome_tests.rs@@ -0,0 +1,50 @@+use super::*;+use tinyinference_llm::message::{AssistantMessage, ContentBlock};+use tinyinference_llm::model::ModelResponse;++fn response(finish_reason: &str, text: &str) -> ModelResponse {+ let content = if text.is_empty() {+ vec![ContentBlock::Thinking {+ text: "still weighing the approach".into(),+ signature: None,+ }]+ } else {+ vec![ContentBlock::text(text)]+ };+ ModelResponse {+ message: AssistantMessage {+ id: None,+ content,+ tool_calls: Vec::new(),+ usage: None,+ origin: None,+ },+ usage: None,+ finish_reason: Some(finish_reason.to_string()),+ raw: None,+ resolved_model: None,+ continue_turn: None,+ served_from_cache: false,+ correlation: None,+ resolved_route: None,+ }+}++#[test]+fn a_length_stop_with_only_reasoning_ran_out_of_output_budget() {+ assert!(ended_out_of_output_budget(Some(&response("length", ""))));+}++#[test]+fn a_length_stop_with_visible_text_is_a_real_answer() {+ assert!(!ended_out_of_output_budget(Some(&response(+ "length",+ "partial answer"+ ))));+}++#[test]+fn a_normal_blank_stop_or_no_final_response_is_not_truncation() {+ assert!(!ended_out_of_output_budget(Some(&response("stop", ""))));+ assert!(!ended_out_of_output_budget(None));+}