Skip to content

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

docs: clarify TinyJuice module ownership

Steven Enamakela80add339d6f
diff --git a/docs/module-boundary-inventory.md b/docs/module-boundary-inventory.md
index e9caf2c3b7..2bd49c882f 100644
--- a/docs/module-boundary-inventory.md
+++ b/docs/module-boundary-inventory.md
@@ -13,7 +13,7 @@ copying its implementation into a host, or accepting weaker isolation.
| Owner | Linked implementation packages | Contract | Host consumers | Required module work |
| --- | --- | --- | --- | --- |
-| tinyjuice | tinyjuice | tinyjuice-bus | core tools, compression, CCR REPL | HTML extraction, query supplied artifacts against module CCR store, schema and tool declarations; retain turn-bound model callbacks |
+| tinyjuice | none (module loaded through TinyBus) | tinyjuice-bus | core tools, compression, CCR REPL | Complete: PR #59 provides module-owned compression, CCR queries, HTML extraction, schemas and declarations; the host retains turn-bound model callbacks and artifact authorization |
| tinyconnectors | tinyconnectors, tinyconnectors-sync | tinyconnectors-bus | core integrations, credentials and triggers | Argument preparation, calendar defaults, task windows, structured provider errors, trigger archives; preserve sign-in/out reconciliation |
| tinymcp | tinymcp | tinymcp-bus | core MCP registry, supervisor, CLI stdio/HTTP server | Supervisor notifications, server protocol operations and callbacks for approved host tools/resources/prompts |
| tinychannels | tinychannels, tinychannels-runtime; runtime/crypto code in contract | tinychannels-bus | core channels and podcast email, TinyHumans host, CLI REPL | Move providers, signing and pairing out of contract; relay config, pairing, start/stop/send/status, inbound/status callbacks, bounded delivery/draining |
@@ -86,7 +86,7 @@ remain unchanged until compatible upstream releases are available.
| Change | Canonical PR | Local verification |
| --- | --- | --- |
| Async HTML extraction seam, deadlines and generic tool-metadata sanitization in TinyTools | [tinytools#60](https://github.com/tinyhumansai/tinytools/pull/60) | 1,183 workspace tests and six doctests; clippy/build; independent sanitizer review accepted; all 113 source files at least 90% coverage |
-| TinyJuice typed CCR/content queries, HTML extraction, pure schemas and declarations | [tinyjuice#59](https://github.com/tinyhumansai/tinyjuice/pull/59) | 737 tests; dynamic artifact E2E; module input/limit guards |
+| TinyJuice typed CCR/content queries, HTML extraction, pure schemas and declarations | [tinyjuice#59](https://github.com/tinyhumansai/tinyjuice/pull/59) | 739 all-feature tests and doctests; compiled-artifact E2E; module input/limit guards |
| Complete TinyDocs Markdown conversion for memory ingestion | [tinydocs#31](https://github.com/tinyhumansai/tinydocs/pull/31) | 183 tests; dynamic artifact E2E; per-file coverage at least 90% |
| TinyHosts pure vocabulary and authorized source preparation with captured deployment bytes | [tinyhosts#21](https://github.com/tinyhumansai/tinyhosts/pull/21) | 210 all-feature and 179 default tests including doctests; compiled snapshot and large legacy deployment probes; pure contract audit; all 19 implementation files at least 90% coverage; independent preparation review accepted |
| TinyComputer native permissions, confidential focus/paste and reliable Globe leases/read/shutdown | [tinycomputer#87](https://github.com/tinyhumansai/tinycomputer/pull/87) | 1,372 all-feature and 1,367 default tests; 90-member compiled artifact verification; independent ownership and event-loss review accepted; macOS cross-check and 233-file coverage gate pass; physical macOS helper not exercised on Linux |
@@ -99,7 +99,7 @@ remain unchanged until compatible upstream releases are available.
| TinyRuntime pure JSONL worker vocabulary, persistent cache recipes, optional provider preparation and module-owned lifecycle | [tinyruntime#29](https://github.com/tinyhumansai/tinyruntime/pull/29) | 244 router unit tests, 6 default / 7 all-feature public API tests, 64 contract tests, 35 pyserver tests and doctests; 13-member compiled artifact verifies old-provider compatibility, preparation, cache reuse, adoption and rebuilding; per-file coverage gate passes; independent cleanup, cache and provider-bridge reviews accepted |
| TinyMCP pure shared vocabulary, supervisor observations, server callbacks and bounded text/argument/tool rendering operations | [tinymcp#54](https://github.com/tinyhumansai/tinymcp/pull/54) | 1,471 all-feature and 1,359 default tests; dynamic 44-member artifact verification; pure contract audit; all 93 source files at least 90% coverage; independent lifecycle, vocabulary and library-feature reviews accepted; external regressions cover module-disabled and host feature combinations |
-The TinyDocs and TinyJuice operations need new published module artifacts.
+The TinyDocs operations need a new published module artifact.
TinyHosts preserves existing member arities and adds authorized preparation inside
Execute; consuming that operation requires a new published artifact. No local build digest
has been used as a release pin, and these PRs do not yet remove any host exception.
diff --git a/gitbooks/developing/architecture/agent-harness.md b/gitbooks/developing/architecture/agent-harness.md
index e443da8ae1..b2b608ace0 100644
--- a/gitbooks/developing/architecture/agent-harness.md
+++ b/gitbooks/developing/architecture/agent-harness.md
@@ -318,7 +318,9 @@ Long tool-calling chains can blow past the context window. Two layers handle tha
Some tool calls return enormous payloads: a Composio action dumping 200 KB of JSON, a web scrape returning 50 KB of markdown, a `file_read` over a multi-thousand-line log. Hard-truncating mid-payload drops whatever happens to land past the cut.
-When a tool result exceeds the summarizer's threshold (`summarizer_payload_threshold_tokens`, default 4 000), TinyJuice's summary stage summarizes it before it enters the parent's history. The parent agent sees only the summary. There is one summarizer, and TinyJuice owns it: it decides when a summary is worth writing, writes the extraction prompt (identifiers and key facts first), caches identical summaries, trips a per-thread breaker after three failures, and offloads the original to CCR so the `juice_retrieve` footer can recover it exactly. The model call itself belongs to the host. `ToolOutputMiddleware` binds a unary child of the current turn through `PayloadSummarizer::prepare`, registers the capped model on a one-off harness (`tinyagents/payload_summarizer.rs`), and the module calls back through `MlHost.Generate`. Only the orchestrator carries a summary model, and it always sees `juice_retrieve`, even with the compaction router off, because a summary's footer names it. A result that qualified for a summary and did not get one is labelled as unsummarized, whether the module or the host failed, so the model does not re-run the tool for one. Summary reuse and the breaker are scoped to the thread, or to the run when there is no thread. Hard truncation remains the downstream backstop when summarization fails, or when the payload is so large that an LLM call on it makes no economic sense.
+When a tool result exceeds the summarizer's threshold (`summarizer_payload_threshold_tokens`, default 4 000), the compiled TinyJuice module decides whether to summarize it before it enters the parent's history. The module owns the extraction prompt, summary cache and per-thread failure breaker, and stores the original in its CCR store so `juice_retrieve` can recover it. The host owns the model call because it knows the model and turn context. `ToolOutputMiddleware` binds a unary child of the current turn through `PayloadSummarizer::prepare`, registers the capped model on a one-off harness (`tinyagents/payload_summarizer.rs`), and the module calls back through the typed `tinyjuice-bus` `MlHost.Generate` contract. Only the orchestrator carries a summary model, and it always sees `juice_retrieve`, even with the compaction router off, because a summary's footer names it. A result that qualified for a summary and did not get one is labelled as unsummarized, whether the module or the host failed, so the model does not re-run the tool for one. Summary reuse and the breaker are scoped to the thread, or to the run when there is no thread. Hard truncation remains the downstream backstop when summarization fails, or when the payload is so large that an LLM call on it makes no economic sense.
+
+Compression, CCR storage and recovery, content queries, HTML extraction, and the static tool declarations and wire DTOs belong to TinyJuice and `tinyjuice-bus`. OpenHuman's tools are adapters: they pass typed requests to the module and keep filesystem authorization on the host side. A handle query runs against the module's CCR store; an artifact query sends authorized content, never a path, to the same module operation. The host has no parallel CCR store or local algorithm fallback. If the module is unavailable, required queries and extraction report that operation as unavailable; optional tool-output compaction keeps its documented pass-through behavior. A resumed thread also keeps its recorded Juice declarations and schemas even when current settings no longer create new handles; current policy and module availability still govern execution.
Caller focus. A tool can opt in to an optional `summary_focus` argument by adding `tokenjuice::focus::summary_focus_property()` to its schema; `web_fetch` and `web_search_tool` do. The model uses it to say what it needs from the result, for example "the rate limits". `before_tool` removes the argument from the call before validation, so the tool never sees it. Only a tool whose schema carries that exact property loses it; any other tool with a parameter of the same name keeps it. It reaches TinyJuice with the result, where it steers the summary, keys its cache, and ranks text for the deterministic compressors. A tool that caps its own output, such as `web_fetch`, is normally left to cap-and-spill. When the caller gives a focus, it is summarized as well, because paging the raw page cannot answer a question.
@@ -361,7 +363,7 @@ Writes log `[artifact] wrote worker artifact under action_dir`; each path a hand
### TokenJuice: content-aware tool-output compaction
-Before a fresh tool result enters history (and ahead of the byte-budget backstop), it passes through the TokenJuice content router in the vendored TinyJuice crate (`vendor/tinyjuice`), with OpenHuman adapters in `crates/openhuman-core/src/inference/tokenjuice/`. Inspired by Headroom, the router _detects the content kind_ (JSON, code, log, search, diff, HTML, plain text) from the bytes and/or a hint derived from the tool name and arguments, then dispatches to a specialised compressor:
+Before a fresh tool result enters history (and ahead of the byte-budget backstop), it passes through the TokenJuice content router inside the compiled TinyJuice module, with OpenHuman adapters in `crates/openhuman-core/src/inference/tokenjuice/`. Inspired by Headroom, the router _detects the content kind_ (JSON, code, log, search, diff, HTML, plain text) from the bytes and/or a hint derived from the tool name and arguments, then dispatches to a specialised compressor:
- JSON → SmartCrusher: array-of-objects → table (each key once), preserving rows that carry errors or numeric outliers.
- Code → tree-sitter (Rust/TS/JS/Python) signature keeper that collapses function bodies; brace-depth heuristic fallback.
diff --git a/gitbooks/features/token-compression.md b/gitbooks/features/token-compression.md
index 699fa4e6ae..d94f276bb5 100644
--- a/gitbooks/features/token-compression.md
+++ b/gitbooks/features/token-compression.md
@@ -9,11 +9,11 @@ icon: file-zipper
LLM tokens cost money, and verbose tool output wastes most of them. A `git status` in a busy repo, a `cargo build` log, a 600-message email thread and a `docker ps -a` against a real cluster can each fill a context window for almost no information.
-OpenHuman ships with TokenJuice, a compression router built into the agent's tool-execution path. Before a tool result reaches a model, TokenJuice classifies it, sends it to a specialized compressor, optionally stores the full original in a recoverable cache, and records how many tokens and dollars it saved. The compression engine is the TinyJuice library, vendored in OpenHuman. The command and log rules come from [vincentkoc/tokenjuice](https://github.com/vincentkoc/tokenjuice).
+OpenHuman ships with TokenJuice, a compression router in the agent's tool-execution path. Before a tool result reaches a model, the compiled TinyJuice module classifies it, selects a compressor, stores recoverable originals in its CCR cache when needed, and returns the compacted result. The module owns compression, CCR retrieval and querying, HTML extraction, and the schemas and request/result types in `tinyjuice-bus`. OpenHuman supplies configuration, filesystem authorization, turn-bound model calls, and savings attribution. The command and log rules come from [vincentkoc/tokenjuice](https://github.com/vincentkoc/tokenjuice).
## The pipeline
-Every tool result takes the same path through the TinyJuice router (`vendor/tinyjuice/src/compress.rs`):
+Every tool result takes the same path through the TinyJuice module's router:
```text
raw tool result
@@ -70,7 +70,7 @@ Multi-byte text (CJK, emoji, combining marks) is handled grapheme by grapheme an
## Handle preview and the juice tools (default)
-Compaction is on by default. For a result of at least `ccr_min_tokens`, the router does not compress to one blob. It stores the original in the CCR cache and shows the model a small preview instead:
+Compaction is on by default. For a result of at least `ccr_min_tokens`, the module stores the original in its CCR cache and shows the model a small preview instead of compressing to one blob:
- a one-line stats description of the shape (estimated tokens, bytes, lines, JSON keys or a Markdown outline, never values),
- the first 500 characters,
@@ -85,7 +85,9 @@ The model then queries the stored original with three read-only tools, none of w
| `juice_extract` | Links or headings from HTML or Markdown output. |
| `juice_summarize` | Size, outline or JSON shape, then head and tail, or the parts most relevant to a `hint`. |
-Answers are size-capped, and an unknown or evicted handle is an error. `juice_retrieve` still returns the whole original. A handle preview is built without a model call, so it also replaces the LLM summary for results big enough to get one. A slow summarizer cannot stall the turn. The three tools are registered (about 1.5 KB of schema) only while this mode is on.
+Answers are size-capped, and an unknown or evicted handle is an error. `juice_retrieve` still returns the whole original. A handle preview is built without a model call, so it also replaces the LLM summary for results big enough to get one. A slow summarizer cannot stall the turn. The three read-only tools are declared by `tinyjuice-bus` and registered for new sessions while this mode is on; resumed sessions keep the declarations recorded in their transcript. Their host adapters send typed queries to the module; they do not read the module cache or repeat its query algorithms locally. For an artifact path, OpenHuman first applies its normal path and size checks, then sends the authorized content to the module without sending the path.
+
+The model's tool catalogue is recorded with each conversation and stays frozen when that thread resumes. If the transcript contains Juice tools, OpenHuman restores their recorded names and schemas even when current settings would not create new handles. The restored tools still use current host path authorization and module policy. A disabled or unavailable module returns an explicit unavailable result for a query; OpenHuman does not substitute a local CCR store or query implementation. Optional output compaction keeps its existing fail-open behavior and returns the unmodified result when the module cannot compact it.
To turn off the whole feature, set `context.compaction_enabled = false` or `OPENHUMAN_COMPACTION=0`. To keep compaction but go back to one-blob compression and `juice_retrieve`, set `tokenjuice.repl_handle_enabled = false` (`OPENHUMAN_TOKENJUICE_REPL_HANDLE_ENABLED=0`). Set `tokenjuice.repl_save_enabled = true` to also write each stored original to `<workspace>/.tokenjuice/repl/<handle>.txt` (mode 0600) so an agent can script over it. That puts raw tool output on disk, and nothing prunes it.
@@ -100,9 +102,9 @@ Besides the deterministic compressors, TokenJuice can route plain text through a
## Nothing is lost: the CCR cache
-Lossy compression normally throws data away. TokenJuice instead stores the full original in the CCR store and leaves a breadcrumb (`vendor/tinyjuice/src/cache/`).
+Lossy compression normally throws data away. TinyJuice instead stores the full original in the module-owned CCR store and leaves a breadcrumb.
-- **In-memory tier** (always on): a process-wide store keyed by SHA-256 hash, bounded by entry count (`max_cache_entries`, default 256) and total bytes (`max_cache_bytes`, default 64 MiB), with FIFO eviction.
+- **In-memory tier** (always on): the module's store is keyed by SHA-256 hash and bounded by entry count (`max_cache_entries`, default 256) and total bytes (`max_cache_bytes`, default 64 MiB), with FIFO eviction.
- **On-disk tier** (optional): `<workspace>/.tokenjuice/ccr/`, enabled with `ccr_disk_enabled`. It survives memory eviction. Set an optional TTL with `ccr_ttl_secs`.
- **The marker:** compacted output ends with a footer like `[compacted tool output: PARTIAL view; full original available via juice_retrieve with token "…"]` carrying the `⟦tj:<hash>⟧` token.
- **Retrieval tool:** the agent calls the read-only `juice_retrieve` tool with that token (optionally a byte or line `range`) to get the full original or a slice. The token is an unguessable SHA-256 digest.