Skip to content

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

fix(agent): handle tool output with no content gracefully

Steven Enamakel00f7445d6079
diff --git a/crates/openhuman-core/src/agent/session_host/builder/setters.rs b/crates/openhuman-core/src/agent/session_host/builder/setters.rs
index 4d208194ec..03ec70d283 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/setters.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/setters.rs
@@ -341,12 +341,12 @@ impl SessionHostBuilder {
self
}
- /// Wire an oversized-tool-result summarizer into the agent. The live
- /// TinyAgents turn path passes it to `ToolOutputMiddleware`, which calls
- /// [`crate::agent::tinyagents::payload_summarizer::PayloadSummarizer::maybe_summarize_in_parent`]
- /// on successful tool output and replaces the raw payload with the
- /// compressed summary on success. Currently set only for the orchestrator
- /// session by [`OpenHumanSessionHost::build_session_agent_inner`].
+ /// Wire the model behind TinyJuice's oversized-tool-result summary into the
+ /// agent. `ToolOutputMiddleware` calls
+ /// [`crate::agent::tinyagents::payload_summarizer::PayloadSummarizer::prepare`]
+ /// for a large result and TinyJuice runs the call if it decides to
+ /// summarize. Currently set only for the orchestrator session by
+ /// [`OpenHumanSessionHost::build_session_agent_inner`].
pub fn payload_summarizer(
mut self,
summarizer: Arc<dyn crate::agent::tinyagents::payload_summarizer::PayloadSummarizer>,
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
index 6552c7392a..f85f6bc429 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -1443,7 +1443,6 @@ impl OpenHumanSessionHost {
let context_mw = TurnContextMiddleware {
tool_result_budget_bytes,
payload_summarizer: self.payload_summarizer.clone(),
- task_hint: None,
// Was `None` in both production constructors; `artifact_wiring`
// documents why its root is the correctness question (#6408, #6483).
artifact_store: Some(artifact_store),
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 f0fdb86207..61a8f5562a 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs
@@ -69,7 +69,7 @@ pub(crate) const COMPACTION_EXEMPT_TOOLS: &[&str] = &[
/// backstop keeps these calls from blowing the context budget.
pub(crate) const SAMPLING_TOOLS: &[&str] = &["get_tool_output_sample", "get_tool_contract"];
-/// Steps 1 (payload summarizer) + 2 (tokenjuice compaction) exemption:
+/// Steps 1 (TinyJuice summary) + 2 (tokenjuice compaction) exemption:
/// proposal tools (final-output contract, see [`COMPACTION_EXEMPT_TOOLS`])
/// plus sampling tools (tabulation would corrupt the schema they exist to
/// reveal, see [`SAMPLING_TOOLS`]).
@@ -264,14 +264,9 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext> for Too
);
}
- // 1. Semantic summarization (progressive disclosure) — swap the raw
- // payload for a compressed summary when the summarizer opts in.
- // Failures never break the tool call, but they are no longer
- // silent: when summarization does not happen the model is told so
- // in the payload itself. This used to be
- // `if let Ok(Some(payload)) = …`, which discarded `Err(_)` and
- // `Ok(None)` identically — so a failed summarization reached the
- // model as an unannounced raw dump and it re-called the same tool.
+ // TinyJuice's "summarization unavailable" notice. A failed summary
+ // never breaks the tool call, but it is not silent either: the model
+ // is told in the payload itself, or it re-calls the same tool.
// Held until after the caps below rather than prefixed here. The notice
// is ~165 chars; a tool declaring a `max_result_size_chars` smaller than
// that had step 3 run `chars().take(cap)` straight through it, cutting
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
index aeea16e757..15045c5949 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
@@ -36,11 +36,8 @@ pub(crate) const DEFAULT_TOOL_RESULT_BUDGET_BYTES: usize = 16 * 1024;
pub(crate) struct TurnContextMiddleware {
/// Per-tool-result byte cap. `0` disables the cap.
pub(crate) tool_result_budget_bytes: usize,
- /// Optional semantic tool-output summarizer (progressive disclosure).
+ /// The model behind TinyJuice's tool-output summary. `None` disables it.
pub(crate) payload_summarizer: Option<Arc<dyn PayloadSummarizer>>,
- /// The user's request for this turn, passed to the payload summarizer as
- /// its task hint. `None` when the turn has no user message to offer.
- pub(crate) task_hint: Option<String>,
/// Optional action-workspace artifact sink for oversized tool results.
pub(crate) artifact_store: Option<ToolResultArtifactStore>,
/// Whether TokenJuice content-aware compaction runs before output caps.
@@ -347,7 +344,6 @@ impl TurnContextMiddleware {
Self {
tool_result_budget_bytes: DEFAULT_TOOL_RESULT_BUDGET_BYTES,
payload_summarizer: None,
- task_hint: None,
// Deliberately `None` on the channel / sub-agent path (#6408).
//
// This constructor has no session context, so it has no
@@ -427,13 +423,13 @@ impl TurnContextMiddleware {
harness.push_middleware(Arc::new(ToolOutputMiddleware {
budget_bytes: self.tool_result_budget_bytes,
payload_summarizer: self.payload_summarizer,
- task_hint: self.task_hint,
artifact_store: self.artifact_store,
tokenjuice_compaction_enabled: self.tokenjuice_compaction_enabled,
tokenjuice_compression: self.tokenjuice_compression,
runtime_config: self.runtime_config,
tool_policies,
artifact_reads: Default::default(),
+ focus_by_call: Default::default(),
}));
}
// Push the handoff LAST (so its `after_tool` runs FIRST): it observes the