Skip to content

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

fix(agent): handle missing tool output in middleware

Steven Enamakel838903e82524
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs
index 5591b97bd7..9f007a57b7 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs
@@ -109,13 +109,21 @@ pub(crate) const DISCOVERY_TOOLS: &[&str] = &["mcp_list_tools", "mcp_list_server
/// Steps 1 (TinyJuice summary) + 2 (tokenjuice compaction) exemption:
/// proposal tools (final-output contract, see [`COMPACTION_EXEMPT_TOOLS`]),
/// sampling tools (tabulation would corrupt the schema they exist to reveal,
-/// see [`SAMPLING_TOOLS`]) and discovery listings (tabulating away a
+/// see [`SAMPLING_TOOLS`]), discovery listings (tabulating away a
/// catalogue's schemas is indistinguishable from not having listed them, see
-/// [`DISCOVERY_TOOLS`]).
+/// [`DISCOVERY_TOOLS`]) and the REPL tools.
+///
+/// The REPL tools (`juice_find`, `juice_extract`, `juice_summarize`) are how the
+/// model reads a result TinyJuice already stored behind a handle. Compacting one
+/// of their answers would store it behind a second handle and hand the model a
+/// preview of a preview, an endless descent. They stay subject to steps 3+4:
+/// each declares a `max_result_size_chars`, so the answer is bounded by the tool
+/// itself and never needs a summary to fit.
pub(crate) fn is_compaction_exempt(name: &str) -> bool {
COMPACTION_EXEMPT_TOOLS.contains(&name)
|| SAMPLING_TOOLS.contains(&name)
|| DISCOVERY_TOOLS.contains(&name)
+ || crate::inference::tokenjuice::is_repl_tool(name)
}
/// Steps 3 (per-tool char cap) + 4 (shared byte-budget backstop) exemption: