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(middleware): handle tool output with no content in turn context
Steven Enamakel959eb3974756
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rsindex ec3d0143fb..0368629bd8 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs@@ -206,6 +206,11 @@ pub(crate) struct ToolOutputMiddleware {/// `after_tool`, where they are not — the same seam `artifact_reads` uses,/// and for the same reason. See [`is_raw_fetch`].pub(crate) raw_fetches: Mutex<std::collections::HashSet<String>>,+ /// Calls that only print files the agent can read again (`cat`, `sed -n`,+ /// `file_read`, ...), keyed by call id; the same `before_tool` →+ /// `after_tool` seam. Their results skip the LLM summary. See+ /// [`super::tool_output_file_read`].+ pub(crate) file_reads: Mutex<std::collections::HashSet<String>>,}impl ToolOutputMiddleware {@@ -299,6 +304,16 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext> for Tooreads.insert(call.id.clone(), read);}}+ if super::tool_output_file_read::is_file_read_call(&call.name, &call.arguments) {+ tracing::debug!(+ tool = %call.name,+ call_id = %call.id,+ "[tinyagents::mw] file read: its result skips the payload summarizer"+ );+ if let Ok(mut reads) = self.file_reads.lock() {+ reads.insert(call.id.clone());+ }+ }if is_raw_fetch(&call.name, &call.arguments) {tracing::debug!(tool = %call.name,@@ -335,6 +350,11 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext> for Too.lock().ok().is_some_and(|mut raw| raw.remove(&call_id));+ let file_read = self+ .file_reads+ .lock()+ .ok()+ .is_some_and(|mut reads| reads.remove(&call_id));let artifact_read = self.artifact_reads.lock()@@ -470,15 +490,35 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext> for Toocapping and spilling to an artifact instead");}+ // A file read is the agent asking for a file's exact text. Within+ // the result budget it goes in verbatim: no summary, no+ // compaction. Past the budget it never gets an LLM summary (a+ // paraphrase of code it is about to edit, which it would only+ // fetch back): TinyJuice's deterministic handle and preview, then+ // step 3's bound, apply. See [`super::tool_output_file_read`].+ let verbatim_file_read = file_read && content.len() <= budget_bytes;+ if file_read {+ tracing::info!(+ tool = tool_name,+ bytes = content.len(),+ budget_bytes,+ verbatim = verbatim_file_read,+ "[tinyagents::mw] file read: no payload summary"+ );+ }if !raw_fetch+ && !verbatim_file_read&& !compaction_exempt&& wants_tinyjuice&& (tool_cap.is_none() || focus.is_some()){// Bind a summary call to this turn only when the result is big// enough for TinyJuice to want one; building the child context for- // every small result would be waste.- let (ticket, unprepared) = match self.summary_ticket(ctx, tool_name, &content) {+ // every small result would be waste. Never for a file read.+ let (ticket, unprepared) = match (!file_read)+ .then(|| self.summary_ticket(ctx, tool_name, &content))+ .flatten()+ {Some(Ok(ticket)) => (Some(ticket), false),Some(Err(())) => (None, true),None => (None, false),diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_tests.rsindex 4fb0740fcc..c8b2d622fb 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_tests.rs@@ -28,6 +28,7 @@ async fn same_tool_calls_persist_artifacts_under_distinct_call_ids() {focus_by_call: Default::default(),summary_focus_tools: Default::default(),raw_fetches: Default::default(),+ file_reads: Default::default(),};let mut ctx = context();diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rsindex 4ad86c82f6..352415fb7d 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs@@ -405,6 +405,7 @@ impl TurnContextMiddleware {focus_by_call: Default::default(),summary_focus_tools,raw_fetches: Default::default(),+ file_reads: Default::default(),}));}}