Skip to content

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

merge: reconcile upstream main

Steven Enamakel7cea7694c3ec
diff --cc crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs
index 15007ff34a,c7b722c967..5591b97bd7
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs
@@@ -83,45 -119,16 +119,47 @@@ pub(crate) fn is_compaction_exempt(name
}
/// Steps 3 (per-tool char cap) + 4 (shared byte-budget backstop) exemption:
- /// proposal tools only. Their JSON is parsed as a single whole-string
- /// document downstream, so any truncation — not just tokenjuice tabulation —
- /// breaks the parse. Sampling tools are deliberately *not* in this set: see
- /// [`SAMPLING_TOOLS`] for why the byte cap stays in force for them.
+ /// proposal tools and discovery listings. A proposal's JSON is parsed as a
+ /// single whole-string document downstream, so any truncation — not just
+ /// tokenjuice tabulation — breaks the parse; a cut catalogue silently drops
+ /// whichever tools sit past the boundary. Sampling tools are deliberately
+ /// *not* in this set: see [`SAMPLING_TOOLS`] for why the byte cap stays in
+ /// force for them.
pub(crate) fn is_truncation_exempt(name: &str) -> bool {
- COMPACTION_EXEMPT_TOOLS.contains(&name)
+ COMPACTION_EXEMPT_TOOLS.contains(&name) || DISCOVERY_TOOLS.contains(&name)
}
+/// Whether this call is a `web_fetch` that asked for the body **as sent**
+/// (`raw: true`), following `use_skill` into the tool it wraps exactly as
+/// [`artifact_read_target`] does.
+///
+/// Such a result is exempt from the payload summarizer (step 2). `web_fetch`
+/// normally returns HTML as Markdown — `tinyjuice::compressors::html::
+/// html_to_markdown`, which drops scripts and styling — and `raw: true` turns
+/// that off, so the payload is unconverted markup. Paying a full-price,
+/// *uncached* model call to have an LLM paraphrase minified JS and CSS is the
+/// worst trade in the ladder: one observed `raw: true` fetch of a 183 KB page
+/// cost 44,561 prompt tokens, over half that turn's entire summarizer budget,
+/// to re-describe a page the same turn had already read as clean Markdown.
+///
+/// It is also the wrong answer to the question asked. A caller who wants the
+/// body as sent wants the bytes, not a summary of them; steps 3–4 still bound
+/// the result and spill the remainder to an artifact the model pages with
+/// `file_read`, which returns the real markup, losslessly and without a model
+/// call.
+fn is_raw_fetch(tool_name: &str, args: &serde_json::Value) -> bool {
+ const FETCH_TOOL: &str = "web_fetch";
+ let (name, args) = if tool_name == "use_skill" {
+ match (args.get("tool").and_then(|t| t.as_str()), args.get("args")) {
+ (Some(inner), Some(inner_args)) => (inner, inner_args),
+ _ => return false,
+ }
+ } else {
+ (tool_name, args)
+ };
+ name == FETCH_TOOL && args.get("raw").and_then(|r| r.as_bool()).unwrap_or(false)
+}
+
/// `after_tool`: apply the semantic payload summarizer (when configured) and
/// then the hard per-tool-result byte cap to each tool result's model-facing
/// content, before it enters the transcript. The graph analogue of the byte cap