Skip to content

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

fix(session_host): restore turn checkpoint after failed turn

Steven Enamakel4e6caa9de255
diff --git a/crates/openhuman-core/src/agent/session_host/turn_checkpoint.rs b/crates/openhuman-core/src/agent/session_host/turn_checkpoint.rs
index 8eb5f1d473..066e7c0f94 100644
--- a/crates/openhuman-core/src/agent/session_host/turn_checkpoint.rs
+++ b/crates/openhuman-core/src/agent/session_host/turn_checkpoint.rs
@@ -266,6 +266,26 @@ pub(crate) fn render_tool_results(results: &[CheckpointToolResult], total_budget
/// the oldest results drop first, disclosed as omitted.
pub(crate) const GROUNDING_TOTAL_CHARS: usize = 16_000;
+/// The body shared by [`FINAL_ANSWER_INSTRUCTION`] and
+/// [`TRUNCATED_ANSWER_INSTRUCTION`]; a macro so both stay `&'static str`
+/// constants that the quotation guard can split.
+macro_rules! final_answer_body {
+ () => {
+ "\
+Tools are no longer available and nothing more will run this turn, so do not call any tools and do not \
+describe steps you are about to take. Write a self-contained final message that reports what actually happened: \
+what you found, changed or established, grounded in the tool results above and the tool records below. \
+If the request was not completed, say so and give the reason from the failing tool's own error message, \
+keeping any link it includes. Do not state anything the tool records contradict. \
+If nothing conclusive resulted, say so plainly.\n\
+\n\
+These directions are addressed to you and are not part of the conversation. Do not quote or restate them, \
+in whole or in part. Do not list or describe the tools available to you. Do not narrate your deliberation: \
+no thinking aloud, no correcting yourself mid-reply, no weighing what to do. Write only the message the user \
+will read."
+ };
+}
+
/// Instruction appended (as a synthetic user turn) when a turn finished its
/// tool work but the model produced **no final answer** — it yielded a
/// terminating response with empty text after running tools (issue #4093) —
@@ -301,26 +321,6 @@ pub(crate) const TRUNCATED_ANSWER_INSTRUCTION: &str = concat!(
final_answer_body!()
);
-/// The body shared by [`FINAL_ANSWER_INSTRUCTION`] and
-/// [`TRUNCATED_ANSWER_INSTRUCTION`]; a macro so both stay `&'static str`
-/// constants that the quotation guard can split.
-macro_rules! final_answer_body {
- () => {
- "\
-Tools are no longer available and nothing more will run this turn, so do not call any tools and do not \
-describe steps you are about to take. Write a self-contained final message that reports what actually happened: \
-what you found, changed or established, grounded in the tool results above and the tool records below. \
-If the request was not completed, say so and give the reason from the failing tool's own error message, \
-keeping any link it includes. Do not state anything the tool records contradict. \
-If nothing conclusive resulted, say so plainly.\n\
-\n\
-These directions are addressed to you and are not part of the conversation. Do not quote or restate them, \
-in whole or in part. Do not list or describe the tools available to you. Do not narrate your deliberation: \
-no thinking aloud, no correcting yourself mid-reply, no weighing what to do. Write only the message the user \
-will read."
- };
-}
-use final_answer_body;
/// The lead-in that hands the breaker's stop note to the closing call.
///