Skip to content

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

refactor(subagent_host): remove unused result cap helper

Steven Enamakeldd4ec1729ea0
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
index 6241875857..cd4ed90a5d 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
@@ -478,8 +478,7 @@ async fn offload_outcome_artifacts(
// Offload at the tighter of the global default and this agent's own result
// cap, so a definition capped below the default (flow_memory_agent at 4 000
- // chars) gets its full body on disk instead of truncated by
- // `apply_max_result_chars` immediately after.
+ // chars) gets its full body on disk instead of truncated immediately after.
let threshold =
effective_offload_threshold(DEFAULT_OFFLOAD_THRESHOLD_BYTES, definition.max_result_chars);
@@ -1049,6 +1048,3 @@ async fn run_typed_mode(
})
}
-#[cfg(test)]
-#[path = "runner_result_cap_tests.rs"]
-mod result_cap_tests;
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner_result_cap.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner_result_cap.rs
deleted file mode 100644
index 8bade1cfe9..0000000000
--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner_result_cap.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-//! Character-safe result caps for delegated agent output.
-
-/// Truncate `output` in place to the definition's `max_result_chars` cap (when
-/// set), appending a `[...truncated]` marker. Char-count based (not byte-length)
-/// to avoid panicking on a multi-byte UTF-8 sequence at the boundary.
-pub(super) fn apply_max_result_chars(output: &mut String, cap: Option<usize>, agent_id: &str) {
- let Some(cap) = cap else { return };
- let original_chars = output.chars().count();
- if original_chars <= cap {
- return;
- }
- tracing::debug!(
- agent_id = %agent_id,
- original_chars,
- cap,
- "[subagent_host] truncating oversized result to max_result_chars cap"
- );
- let byte_offset = output
- .char_indices()
- .nth(cap)
- .map(|(i, _)| i)
- .unwrap_or(output.len());
- output.truncate(byte_offset);
- output.push_str("\n[...truncated]");
-}
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner_result_cap_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner_result_cap_tests.rs
deleted file mode 100644
index b3e7a0bc2d..0000000000
--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner_result_cap_tests.rs
+++ /dev/null
@@ -1,35 +0,0 @@
-use super::apply_max_result_chars;
-
-#[test]
-fn max_result_chars_none_is_noop() {
- // No cap → output untouched (the `agent_memory` default).
- let mut out = "hello world".to_string();
- apply_max_result_chars(&mut out, None, "worker");
- assert_eq!(out, "hello world");
-}
-
-#[test]
-fn max_result_chars_under_cap_is_noop() {
- let mut out = "short".to_string();
- apply_max_result_chars(&mut out, Some(100), "worker");
- assert_eq!(out, "short");
-}
-
-#[test]
-fn max_result_chars_over_cap_truncates_with_marker() {
- let mut out = "x".repeat(50);
- apply_max_result_chars(&mut out, Some(10), "worker");
- assert!(out.starts_with(&"x".repeat(10)), "{out}");
- assert!(out.ends_with("[...truncated]"), "{out}");
- // 10 kept chars + the marker, and shorter than the 50-char original.
- assert!(out.chars().count() < 50, "{out}");
-}
-
-#[test]
-fn max_result_chars_truncates_on_char_boundary_for_multibyte() {
- // Cap lands mid-run of multi-byte chars; must not panic or split a char.
- let mut out = "é".repeat(20); // each 'é' is 2 bytes
- apply_max_result_chars(&mut out, Some(5), "worker");
- assert!(out.starts_with(&"é".repeat(5)), "{out}");
- assert!(out.ends_with("[...truncated]"), "{out}");
-}