Skip to content

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

docs(tokenjuice): describe module-only recovery and extraction

Steven Enamakel70209ef78c64
diff --git a/crates/openhuman-core/src/inference/tokenjuice/README.md b/crates/openhuman-core/src/inference/tokenjuice/README.md
index 0eb896c388..f8bc04571f 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/README.md
+++ b/crates/openhuman-core/src/inference/tokenjuice/README.md
@@ -1,10 +1,9 @@
# OpenHuman TokenJuice Adapter
-The reusable compression engine ships as the separately released `tinyjuice`
-TinyBus module. Its stateful half, the router, the CCR cache, the rule engine,
-ranged retrieval, runs there and is reached only over the bus; its stateless
-content transforms are linked directly (see "What is linked" below). This
-directory is the host adapter and shared wire-contract layer.
+TinyJuice ships as a separately released TinyBus module. OpenHuman links only
+its `tinyjuice-bus` vocabulary and declarations. Compression, cached retrieval,
+queries and HTML extraction execute inside that module. This directory owns
+configuration, model callbacks, artifact authorization and savings attribution.
Token compression is one of the ways OpenHuman keeps a turn cheap and fast
(see [gitbooks/developing/performance.md](../../../../../gitbooks/developing/performance.md)):
@@ -22,7 +21,7 @@ OpenHuman-owned files:
| [`schemas.rs`](./schemas.rs) | JSON-RPC controller schemas and handlers. |
| [`config_patch.rs`](./config_patch.rs) | Partial update shape for the `[tokenjuice]` config block. |
| [`generate.rs`](./generate.rs) | Turn-bound, single-use summary callbacks. The host registers the model call, sends its opaque ticket through the existing contract, and withdraws the callback when the ticket drops. |
-| [`repl_tools.rs`](./repl_tools.rs) | The three REPL tools (`juice_find`, `juice_extract`, `juice_summarize`) over a stored result. TinyJuice owns the ops and declarations (`tinyjuice::repl::tools`, cargo feature `tinytools`); the CCR store lives in the module, so each call fetches the original with `Retrieve` and hands the stock tool a one-entry store. Registered by [`tools/ops.rs`](../../tools/ops.rs) only while `repl_handle_active(config)`. |
+| [`repl_tools.rs`](./repl_tools.rs) | The three REPL tools (`juice_find`, `juice_extract`, `juice_summarize`) over a stored result. Declarations come from `tinyjuice-bus`; operations execute over `Query` inside the module CCR store. Registered by [`tools/ops.rs`](../../tools/ops.rs) only while `repl_handle_active(config)`. |
| [`tools.rs`](./tools.rs) | OpenHuman agent tool implementation for the retrieve tool (`RETRIEVE_TOOL_NAME = "juice_retrieve"`; `"tokenjuice_retrieve"` is a recognized recovery-tool alias, not the tool's registered name, see `RECOVERY_TOOL_NAMES`). |
| `ml/` | Bridge from TinyJuice's optional ML callback into the shared `runtime::python_server` Kompress backend (ModernBERT token/sentence salience); opt-in via `config.tokenjuice.ml_compression_enabled` (default off), degrades gracefully when the flag is off or the runtime server is unavailable. |
| [`savings.rs`](./savings.rs) | OpenHuman model-pricing attribution and persisted dashboard stats. |
@@ -38,54 +37,26 @@ TinyJuice-owned engine pieces:
| `src/vendor/rules/*.json` | Vendored upstream rule JSON files. |
| `src/detect/`, `text/`, `tokens.rs`, `types.rs` | Detection, text helpers, token estimates, public types. |
-## What is linked, and what stays behind the module boundary
+## Module boundary
-The rule is no longer "the crate is never linked". It is **stateful engine
-behavior stays behind the module boundary; stateless content transforms do
-not.**
+`tinyjuice-bus` owns the serialized request/result types, schemas and tool
+declarations. The host's `juice_find`, `juice_extract` and `juice_summarize`
+adapters send `Query` requests with opaque CCR handles. They never fetch the
+original to run a local query. Artifact queries retain OpenHuman's traversal,
+canonical containment and size checks, then send authorized content without
+a filesystem path.
-`openhuman-core` depends on `tinyjuice` directly, with
-`default-features = false` (dropping `tinyjuice-treesitter` and its three
-tree-sitter grammars, which serve the code compressor) and the `tinytools`
-feature. It calls the pure half, and takes the REPL tool declarations:
-
-| Linked and called directly | Why it may be |
-| --- | --- |
-| `repl::tools::repl_tools` | Only the declarations and the stateless ops. The store they read is the module's, reached over `Retrieve`. `tinytools` resolves to the one copy `tinyagents` vendors (root `[patch]`), so these are the harness's `Tool` type. |
-| `compressors::html::html_to_markdown` | Pure `&str -> String`. `web_fetch` runs it on every HTML response so the model reads a page's prose, headings and links instead of its minified JS. |
-
-Everything with state stays where it was, reached only through TinyBus:
-
-| Behind the module boundary | Why it stays |
-| --- | --- |
-| `compress::route` / `compress_content` | Picks a compressor from the rule engine and records savings. |
-| `cache/`: the CCR store, retrieval markers, disk tier, ranged retrieval | Owns a disk tier and a marker vocabulary (`⟦tj:<hash>⟧`) the module must resolve. `juice_retrieve` is the model-facing half and is unchanged. |
-| `rules/`, `reduce/`, `ml/` | Rule tables, execution reduction, the ModernBERT callback. |
-
-Why a content transform is not allowed to go through the bus: reaching it there
-needs the `modules` feature, a loaded cdylib, and `config.tokenjuice` /
-`context.compaction_enabled`: which a user can switch off. A core tool's default
-output would then depend on whether an optional module happened to load, so the
-same URL would come back as Markdown on one install and as raw markup on
-another. That is not a defensible way to decide what a fetched page looks like.
-
-Why the transform is not reimplemented in OpenHuman instead: TinyJuice owns
-content handling, a second copy would drift from the first, and its scanner
-already handles CDATA sections, `>` inside quoted attribute values, and
-unterminated quotes. A host-side rewrite was prototyped and thrown away in
-favour of extending `html_to_markdown` upstream.
-
-Anything beyond a pure transform still belongs behind the boundary: runtime
-services, settings persistence, JSON-RPC, tools, pricing, and the optional ML
-callback stay here.
+`web_fetch` uses TinyTools' asynchronous HTML adapter: `Detect` and
+`ExtractHtml` execute in the module independently of the compression setting.
+An unavailable module fails that affected operation with a sanitized terminal
+report. Optional output compaction preserves its existing disclosed pass-through
+behavior. There is no linked implementation fallback.
## Wiring
-- `mod.rs::proxy` (behind the `modules` feature) loads the module via
- `crate::modules::ensure_loaded(config, "tinyjuice")`, looks it up with
- `crate::modules::registry::find("tinyjuice")`, and calls through
- `crate::modules::host::runtime()`; without the feature `proxy` errors and the
- pass-through fallback applies.
+- `mod.rs::client` uses the shared `ModuleClient` and process-wide lazy loader.
+ Explicit configuration and bundled artifact discovery remain host-owned.
+ Builds without `modules` return an unavailable error.
- Controllers are registered from `crate::inference::tokenjuice::all_tokenjuice_registered_controllers()`,
called by [`core/all.rs`](../../core/all.rs).
- `tools/ops.rs` registers `crate::inference::tokenjuice::TokenjuiceRetrieveTool::new()`
@@ -106,8 +77,8 @@ callback stay here.
test, `session_host/builder/mod.rs::ensure_repl_tools_visible` adds them to a
curated belt, and `middleware/tool_output.rs::is_compaction_exempt` keeps
their answers from being stored behind a second handle (their own
- `max_result_size_chars` still caps them). The bus `Repl` member is not used
- from here: it is not yet a `tinyjuice-bus` name constant.
+ `max_result_size_chars` still caps them). The additive `Query` member carries the typed operation; existing `Repl`
+ arity is unchanged.
- Contract crate: `tinyjuice-bus` ([`vendor/tinyjuice/crates/tinyjuice-bus`](../../../../../vendor/tinyjuice/crates/tinyjuice-bus/),
path dependency in [`crates/openhuman-core/Cargo.toml`](../../../Cargo.toml)).
diff --git a/crates/openhuman-core/src/platform/about_app/catalog_conversation_intelligence.rs b/crates/openhuman-core/src/platform/about_app/catalog_conversation_intelligence.rs
index 3814bc0038..d7bc56ed96 100644
--- a/crates/openhuman-core/src/platform/about_app/catalog_conversation_intelligence.rs
+++ b/crates/openhuman-core/src/platform/about_app/catalog_conversation_intelligence.rs
@@ -373,6 +373,16 @@ Capability {
status: CapabilityStatus::Beta,
privacy: MEMORY_TO_REMOTE_ENGINE,
},
+Capability {
+ id: "intelligence.tool_output_recovery",
+ name: "Tool Output Recovery",
+ domain: "tokenjuice",
+ category: CapabilityCategory::Intelligence,
+ description: "Large tool outputs stay recoverable by their saved handles. The assistant can search, extract or summarize selected parts without retrieving the entire original. Recovery and web-page extraction require the TinyJuice module; if it is unavailable, the affected operation reports an error.",
+ how_to: "The assistant uses juice_find, juice_extract, juice_summarize and juice_retrieve when a tool result includes a recovery handle.",
+ status: CapabilityStatus::Beta,
+ privacy: RAW_TO_INFERENCE_PROVIDER,
+ },
Capability {
id: "intelligence.context_breakdown",
name: "Context Window Breakdown",
diff --git a/crates/openhuman-core/src/tools/impl/README.md b/crates/openhuman-core/src/tools/impl/README.md
index 16137f6bb1..b87e7fc4ff 100644
--- a/crates/openhuman-core/src/tools/impl/README.md
+++ b/crates/openhuman-core/src/tools/impl/README.md
@@ -29,7 +29,7 @@ tested but no production assembly site constructs it today.
| Family | Tools | Registration gate |
| --- | --- | --- |
-| [`system/`](./system/) | `ShellTool`, `NodeExecTool`, `NpmExecTool`, `PythonExecTool`, `InstallToolTool`, `DetectToolsTool` (from `tinytools_std`), `CurrentTimeTool` and `ResolveTimeTool` (imported directly from `tinyagents_harness::tools` at their call sites; no local copy), `ScheduleTool`, `ProxyConfigTool`, `PushoverTool`, `LspTool`, `ToolStatsTool`, `UpdateCheckTool`, `UpdateApplyTool`, `InsertSqlRecordTool`, `WorkspaceStateTool`, `RetrieveToolOutputTool` (from `tinyjuice::host`, wired by `retrieve_tool_output_tool`); shell failure rendering lives in `tinytools_std::command_output` | `node_exec`/`npm_exec` and `shell`'s PATH injection need the `runtime-node` Cargo feature plus `node.enabled`; `python_exec` needs `runtime_python.enabled`; `LspTool` needs `OPENHUMAN_LSP_ENABLED` (`lsp_capability_enabled`); `ToolStatsTool` needs `learning.enabled` and `learning.tool_tracking_enabled`; `InsertSqlRecordTool` is exported, not registered; the rest are always registered |
+| [`system/`](./system/) | `ShellTool`, `NodeExecTool`, `NpmExecTool`, `PythonExecTool`, `InstallToolTool`, `DetectToolsTool` (from `tinytools_std`), `CurrentTimeTool` and `ResolveTimeTool` (imported directly from `tinyagents_harness::tools` at their call sites; no local copy), `ScheduleTool`, `ProxyConfigTool`, `PushoverTool`, `LspTool`, `ToolStatsTool`, `UpdateCheckTool`, `UpdateApplyTool`, `InsertSqlRecordTool`, `WorkspaceStateTool`, `RetrieveToolOutputTool` (host adapter using TinyJuice bus declarations and retrieval); shell failure rendering lives in `tinytools_std::command_output` | `node_exec`/`npm_exec` and `shell`'s PATH injection need the `runtime-node` Cargo feature plus `node.enabled`; `python_exec` needs `runtime_python.enabled`; `LspTool` needs `OPENHUMAN_LSP_ENABLED` (`lsp_capability_enabled`); `ToolStatsTool` needs `learning.enabled` and `learning.tool_tracking_enabled`; `InsertSqlRecordTool` is exported, not registered; the rest are always registered |
| [`filesystem/`](./filesystem/) | Host adapter only: `SecurityPolicy` implements `tinytools_std::filesystem::FsGate`. The tools (`FileReadTool`, `FileWriteTool`, `EditFileTool`, `ApplyPatchTool`, `GrepTool`, `GlobTool`, `ListFilesTool`, `ReadDiffTool`, `CsvExportTool`, `GitOperationsTool`, `RunLinterTool`, `RunTestsTool`, `UpdateMemoryMdTool`) live in `tinytools_std::filesystem` and are imported directly by `tools/ops.rs` | always registered, except `ReadDiffTool`, `RunLinterTool`, and `RunTestsTool`, which are exported, not registered |
| [`browser/`](./browser/) | `BrowserTool` (TinyComputer browser members and tasks), `BrowserOpenTool` (simple TinyComputer navigation), `ImageInfoTool` | Both browser tools need `browser.enabled` and the `modules` feature, and are deferred until `tool_search`; `ImageInfoTool` remains direct. Browser navigation uses the shared `http_request.allowed_domains` policy, and the checksum-pinned TinyComputer release module. Consequential actions go through the forced approval gate; `browser_unattended.rs` lets trusted cron/background/approval-free workflow turns skip it for the kinds listed in `[browser] unattended_actions`. |
| [`network/`](./network/) | `HttpRequestTool`, `WebFetchTool`, `CurlTool`, `GitbooksSearchTool`, `GitbooksGetPageTool`, `GmailUnsubscribeTool`, and under the `mcp` Cargo feature `McpListServersTool`, `McpListToolsTool`, `McpCallTool`; `url_guard.rs` is the shared SSRF/allowlist validator, not a tool | `http_request`, `web_fetch`, `curl`, `gmail_unsubscribe` always registered; `gitbooks_*` need `gitbooks.enabled` and, when the active profile sets an `mcp_allowlist`, an entry named `gitbooks`; `mcp_list_servers`/`mcp_list_tools`/`mcp_call_tool` register only when the static `[[mcp_client.servers]]` registry (after the profile allowlist) is non-empty |
diff --git a/docs/module-boundary-inventory.md b/docs/module-boundary-inventory.md
index bbc3a6b6db..636c49c294 100644
--- a/docs/module-boundary-inventory.md
+++ b/docs/module-boundary-inventory.md
@@ -208,9 +208,10 @@ TinyJuice [#59](https://github.com/tinyhumansai/tinyjuice/pull/59) merged as
canonical base. Fresh locked all-feature tests passed (739 tests and doctests),
and a separately run compiled-artifact TinyBus test passed. Both final hosted
Rust jobs passed, with approval and zero unresolved threads. Minor release run
-38091415272 is building the eleven shipped-platform artifacts; the new HTML
-and query host callers remain pending compatible released artifacts and digest
-pins. The isolated `module-tinyjuice-host` checkout now owns the turn-bound
+38091415272 succeeded. The eleven v0.7.0 platform archives have been downloaded
+and verified against both published checksums and GitHub asset digests. The
+source pin is `b89632a8f7b96580a9f6718d185eb60b14a41a8a`; HTML and query
+adapters now use the module, with host-loader interoperability checks pending. The isolated `module-tinyjuice-host` checkout now owns the turn-bound
summary callback registry instead of re-exporting its implementation from
TinyJuice; its 57 TokenJuice domain tests pass using the existing callback DTO.
diff --git a/vendor/tinyjuice b/vendor/tinyjuice
index b134e70514..b89632a8f7 160000
--- a/vendor/tinyjuice
+++ b/vendor/tinyjuice
@@ -1 +1 @@
-Subproject commit b134e7051441e716b4c3749d03a3c17bbee7164f
+Subproject commit b89632a8f7b96580a9f6718d185eb60b14a41a8a