#6801·openhuman

TinyJuice LLM summary blocks agent turns for 15–30s per large tool result

Author: senamakelCreated Sep 30, 2026Updated Sep 30, 2026
Labelsperformancerust-corecomposiobugharnesspriority: p1

Summary

TinyJuice's LLM summary step blocks the agent turn for 6–32 s on every tool result larger than ~16 KB. In one desktop session (a GitHub code search, then writing a doc into Notion), 14 summaries added 269 s of wall-clock time, about 19 s each. The tools themselves returned in 1–2 s. Composio results (GITHUB_*, NOTION_*) are hit hardest because they never declare a result cap, so they always get an LLM summary.

Update: per-call token analytics (comment) show the stall is decode-bound. Latency correlates with the summary's output tokens (r = 0.99), not its input (r = 0.31). Summaries run 2–4k output tokens at ~120 tok/s, and 34% of those are reasoning tokens. Capping summarizer output and disabling reasoning for the summarizer role is the biggest single lever. Sanitized run timelines and a redacted transcript skeleton are attached in the comments below.

Problem

Observed: after a large tool result there is a 15–30 s gap with no visible progress before the agent continues. The model call has finished and the tool has returned. The turn is waiting on ToolOutputMiddleware::after_tool, which awaits a TinyJuice CompactWith. That call issues MlHost.Generate, which runs a separate summarizer child model call on the raw payload.

Expected: a large tool result is bounded in a few hundred ms. That could be deterministic compaction, or an artifact spill with file_read paging. A model summary should run only when it is worth its latency, and never serialized one after another across a batch.

Environment: OpenHuman desktop, core 0.64.7, macOS 26.5.1 (arm64), tinyjuice module 0.3.4. Orchestrator model openrouter/deepseek/deepseek-v4-flash; default_model = openrouter/z-ai/glm-5.3-flash. Relevant config: summarizer_payload_threshold_tokens = 4000, summarizer_max_payload_tokens = 2000000, [agent] parallel_tools = false.

Steps to reproduce

  1. Connect the GitHub and Notion integrations (Composio).
  2. In web chat, ask the agent to search a GitHub repo's code for something broad, then write a doc/script into a Notion page from the findings.
  3. Watch the core log for [tokenjuice::generate] served … purpose=tool_output_summary and [tinyagents::mw] tinyjuice summarized tool output.

Measurements (from ~/.openhuman/logs/openhuman.<date>.log)

Time Tool Summarizer prompt (bytes) Summary (bytes) Summary latency
14:09:47 GITHUB_SEARCH_CODE 134,342 4,631 17.1 s
14:10:05 GITHUB_SEARCH_CODE 134,208 3,840 15.9 s
14:10:26 GITHUB_SEARCH_CODE 134,078 4,444 18.8 s
14:10:57 GITHUB_SEARCH_CODE 133,252 5,684 29.5 s
14:11:21 web_fetch 17,955 3,643 17.3 s
14:11:43 web_fetch 37,329 3,458 12.7 s
14:13:40 NOTION_SEARCH_NOTION_PAGE 28,028 3,217 16.1 s
14:14:15 tool_search 19,865 1,784 6.4 s
14:17:26 NOTION_ADD_MULTIPLE_PAGE_CONTENT 72,486 7,343 24.8 s
14:19:14 NOTION_FETCH_BLOCK_CONTENTS 72,469 6,004 23.4 s
14:19:54 NOTION_FETCH_BLOCK_CONTENTS 72,469 4,235 17.2 s
14:20:26 NOTION_FETCH_BLOCK_CONTENTS 80,129 5,827 22.1 s
14:21:17 NOTION_FETCH_BLOCK_CONTENTS 39,342 4,983 31.9 s
14:26:29 NOTION_ADD_MULTIPLE_PAGE_CONTENT 53,880 2,396 15.6 s
Total (14 calls) 269.1 s (avg 19.2 s)

Additional observations:

  • Summaries run one after another. The four GitHub searches were summarized back to back. Each [subagent_host] resolved … agent_id="summarizer" line appears about 2 s after the previous summary finishes, which puts 17 + 16 + 19 + 30 ≈ 81 s on the critical path for one batch.
  • The summarizer gets the raw payload. prompt_bytes ≈ from_bytes + ~300 bytes of instructions (134,342 vs 134,040). The deterministic JSON compaction did not shrink the payload before the model saw it, so each call is a ~33k-token prefill.
  • It runs on a different model with a cold cache. The summarization hint resolved to default_model (glm-5.3-flash) while the turn ran on deepseek-v4-flash. No prefix cache is shared, so every summary is a full cold prefill.
  • Identical results are summarized twice. Two NOTION_FETCH_BLOCK_CONTENTS results were byte-identical (72,159 bytes raw) and were each summarized (23.4 s + 17.2 s). The per-scope summary reuse did not catch the second one.
  • The pre-summary tool calls completed quickly. For example, tool_search answered in 3,980 ms, and round 1 had first_tool_ms=4510.

Root cause

  1. The summary blocks the turn. crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs (after_tool, steps 1+2) awaits inference::tokenjuice::compact_tool_output. TinyJuice then calls back into inference::tokenjuice::generate::serve, which runs SubagentPayloadSummarizer (agent/tinyagents/payload_summarizer.rs) as a unary child model call. The result is not appended until that returns, and the only timeout is COMPACT_WITH_TIMEOUT = 330 s (inference/tokenjuice/mod.rs:223).
  2. The trigger is broad. summary_ticket fires at estimate_output_tokens >= summarizer_payload_threshold_tokens (default 4000 ≈ 16 KB). The only escape is tool_cap.is_some() without a summary_focus. Composio actions declare no max_result_size_chars, so every large GITHUB_*/NOTION_* response pays for a model call, even though step 3 (artifact spill + file_read paging) would bound it losslessly for free.
  3. Summary before compaction. The model call sees the unreduced payload. For JSON-heavy Composio responses the deterministic compressors could plausibly remove most of the bytes first, but here they did not run ahead of the summary. This ordering lives in the tinyjuice module.
  4. The summary model is not chosen for latency. agent/registry/agents/summarizer/agent.toml uses hint = "summarization", which falls back to the user's default_model when no route is set. That can be a slow model, and it never shares a cache with the turn's model.
  5. Serialized in the harness. finish_tool_call in vendor/tinyagents/crates/tinyagents-harness/src/agent_loop/tools.rs runs run_after_tool per call with &mut ctx, so even with parallel_tools = true each summary in a batch waits for the one before it.

Solution (proposed)

Ordered roughly by impact/effort:

  • Deduplicate repeated JSON sub-objects before any summary. 89% of each GITHUB_SEARCH_CODE payload (127,951 of ~144,000 bytes) is the identical items[].repository object repeated ×30. Deduped, the payload is ~15 KB, under the threshold, so no model call is needed (comment). (tinyjuice module / Composio response shaping)
  • Track separately: two web_fetch calls to raw.githubusercontent.com hit the 30 s timeout (60 s of stall) with an opaque error sending request, while sibling fetches took 300–700 ms.
  • Cap the summarizer's output tokens (for example 512–800) and disable reasoning for the summarizer role. Today max_output_tokens falls back to AGENT_TURN_MAX_OUTPUT_TOKENS. (openhuman, payload_summarizer.rs / summarizer/agent.toml)
  • Report summary time apart from tool time. tool_completed.duration_ms currently includes the summary, so GITHUB_SEARCH_CODE reads as 22 s when the tool took ~5 s. (tinyagents / openhuman)
  • Give Composio actions a default result cap (for example 16–32 KB) so they take the step-3 spill path. The LLM summary would then run only when the model passes summary_focus. (openhuman, integrations/composio)
  • Compact before summarizing: run the deterministic compressors first and only ask for a summary if the compacted output is still over threshold. (tinyjuice module)
  • Route the summarization hint to a fast, cheap model by default instead of falling back to default_model, and log the resolved model plus its TTFB. (openhuman)
  • Bound the summary with a short timeout (for example 8 s) and fall back to compaction + spill, instead of the 330 s CompactWith ceiling. (openhuman / tinyjuice)
  • Deduplicate on content hash so an identical payload in the same scope reuses the earlier summary. (tinyjuice)
  • Run summaries for one tool batch concurrently (or move summarization out of the ordered after_tool step). (tinyagents)
  • Surface the wait in the UI (for example a "summarizing large result…" progress event), so a 20 s gap does not look like a hang.
  • Short-term workaround: raise summarizer_payload_threshold_tokens in config.toml, or disable the payload summarizer.

Acceptance criteria

  • Repro gone: the GitHub search + Notion write flow no longer shows multi-second tool_output_summary stalls per call. p95 added latency per large Composio result is under ~2 s without summary_focus.
  • No capability loss: oversized results remain fully recoverable through the artifact + file_read paging handle.
  • Regression safety: tests for (a) the Composio default cap skipping the summary, (b) the summary timeout falling back to compaction, (c) identical payloads reusing one summary.
  • Diff coverage ≥ 80%.
  • Upstream PRs in tinyjuice / tinyagents for the module- and harness-owned parts, with gitlinks bumped here.

Related

  • crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs (summary_ticket, after_tool steps 1–3)
  • crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs
  • crates/openhuman-core/src/inference/tokenjuice/{mod.rs,generate.rs}
  • crates/openhuman-core/src/agent/registry/agents/summarizer/agent.toml
  • vendor/tinyagents/crates/tinyagents-harness/src/agent_loop/tools.rs (finish_tool_call)
  • #6283 (summary byte-count disclosure, same middleware)