Skip to content

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

refactor(session_host): route close copy through product_copy helpers

Steven Enamakel8536f330f16e
diff --git a/crates/openhuman-core/src/agent/session_host/driver.rs b/crates/openhuman-core/src/agent/session_host/driver.rs
index 7c26dc6dbb..cf8c4b6934 100644
--- a/crates/openhuman-core/src/agent/session_host/driver.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver.rs
@@ -331,11 +331,13 @@ impl SessionDriver<OpenHumanRunContext> for OpenHumanSessionDriver {
if outcome.text.trim().is_empty()
&& output.starts_with("I finished this turn without writing up a result.")
{
- output = crate::agent::session_host::turn_checkpoint::build_deterministic_checkpoint(
- &crate::agent::session_host::turn_checkpoint::results_from_tool_outcomes(
- &outcome.tool_outcomes,
- ),
+ let results = super::product_copy::close_results(&outcome.tool_outcomes);
+ let rendered = super::product_copy::render_close_results(&results, 4_000);
+ output = tinyagents_harness::close::checkpoint_with_copy(
+ &super::product_copy::OPENHUMAN_CLOSE_COPY,
self.max_iterations,
+ &rendered,
+ !results.is_empty(),
);
}
let mut history = request.history;
diff --git a/crates/openhuman-core/src/agent/session_host/driver/helpers.rs b/crates/openhuman-core/src/agent/session_host/driver/helpers.rs
index 182d8c0141..44948d4fb8 100644
--- a/crates/openhuman-core/src/agent/session_host/driver/helpers.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver/helpers.rs
@@ -115,13 +115,8 @@ pub(super) fn driver_error_with_snapshot(
// The model's streamed narration was stopped before it could repeat
// indefinitely. Preserve the completed tools as a useful, bounded
// partial rather than showing only the failed model's process text.
- let results = crate::agent::session_host::turn_checkpoint::results_from_tool_outcomes(
- &guard.tool_outcomes,
- );
- let evidence = crate::agent::session_host::turn_checkpoint::render_tool_results(
- &results,
- crate::agent::session_host::turn_checkpoint::CHECKPOINT_TOTAL_CHARS,
- );
+ let results = crate::agent::session_host::product_copy::close_results(&guard.tool_outcomes);
+ let evidence = crate::agent::session_host::product_copy::render_close_results(&results, 4_000);
format!(
"I stopped a repetitive model response before it could finish. Here are the completed tool results I can report:\n{evidence}"
)
diff --git a/crates/openhuman-core/src/agent/session_host/product_copy.rs b/crates/openhuman-core/src/agent/session_host/product_copy.rs
index e30ab6f5cb..0a8de4fb2c 100644
--- a/crates/openhuman-core/src/agent/session_host/product_copy.rs
+++ b/crates/openhuman-core/src/agent/session_host/product_copy.rs
@@ -17,3 +17,48 @@ pub(crate) const OPENHUMAN_STOP_COPY: tinyagents_harness::turn_stop::StopCopy =
/// OpenHuman's prompt and fallback wording for generic TinyAgents close paths.
pub(crate) const OPENHUMAN_CLOSE_COPY: tinyagents_harness::close::CloseCopy =
tinyagents_harness::close::ENGLISH_CLOSE_COPY;
+
+/// Capture bounded result text for the OpenHuman checkpoint and close paths.
+pub(crate) fn close_results(
+ outcomes: &[tinyagents_harness::turn_outcome::ToolCallOutcome],
+) -> Vec<tinyagents_harness::close::CloseToolResult> {
+ tinyagents_harness::close::results_from_tool_outcomes_with_options(
+ outcomes,
+ 800,
+ "… [truncated]",
+ )
+}
+
+/// Render captured results with OpenHuman's established block format.
+pub(crate) fn render_close_results(
+ results: &[tinyagents_harness::close::CloseToolResult],
+ total_budget: usize,
+) -> String {
+ tinyagents_harness::close::render_tool_results_with_options(
+ results,
+ tinyagents_harness::close::CloseResultRenderOptions {
+ per_result_cap: 800,
+ truncation_marker: "… [truncated]",
+ total_budget,
+ render_block: |result| {
+ let status = if result.success { "ok" } else { "failed" };
+ let mut block = format!("\n- `{}` — {}\n", result.name, status);
+ for line in result.content.lines() {
+ block.push_str(" > ");
+ block.push_str(line);
+ block.push('\n');
+ }
+ block
+ },
+ omitted_notice: |count| {
+ if count == 0 {
+ String::new()
+ } else {
+ format!(
+ "\n_({count} earlier tool result(s) omitted for length — the most recent are shown.)_\n"
+ )
+ }
+ },
+ },
+ )
+}
diff --git a/crates/openhuman-core/src/agent/tinyagents/context_wiring.rs b/crates/openhuman-core/src/agent/tinyagents/context_wiring.rs
index 7689dc0eb0..47ee3050fd 100644
--- a/crates/openhuman-core/src/agent/tinyagents/context_wiring.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/context_wiring.rs
@@ -135,8 +135,10 @@ pub(super) fn install_context_ladder(
let wrap_up = wrap_up_at_cap.then(|| {
Arc::new(
FinalCallWrapUpMiddleware::new(
- crate::agent::session_host::turn_checkpoint::MAX_ITER_CHECKPOINT_INSTRUCTION,
- crate::agent::session_host::turn_checkpoint::FINAL_WRITE_INSTRUCTION,
+ crate::agent::session_host::product_copy::OPENHUMAN_CLOSE_COPY
+ .max_iteration_instruction,
+ crate::agent::session_host::product_copy::OPENHUMAN_CLOSE_COPY
+ .final_write_instruction,
Arc::new(OutcomeSinkSource(tool_outcome_sink.clone())),
restore_allowance,
)