-
Notifications
You must be signed in to change notification settings - Fork 1
OpenHuman Integration
TinyJuice is built for OpenHuman, but the core crate does not depend on OpenHuman runtime internals. Hosts provide policy through adapter calls, callbacks, and plain configuration structs.
Primary function:
compact_tool_output_with_policy(
tool_name: &str,
arguments: Option<&serde_json::Value>,
output: &str,
exit_code: Option<i32>,
profile: AgentTokenjuiceCompression,
) -> (String, CompactionStats)The adapter:
- resolves the agent profile
- skips recovery tools
- extracts command/argv from tool arguments
- extracts extension and query hints
- builds
CompressInput - calls the router
- returns final text plus stats
| Profile | Behavior |
|---|---|
Off |
Returns original output unchanged |
Light |
Disables CCR and ML; lossy compressors decline |
Full |
Uses current global options |
Auto |
Treated as Full inside TinyJuice; hosts may resolve it first |
Light is the safer profile for coding agents that need exact command output.
Full is the stronger profile for exploratory, research, or high-volume tool
flows where recoverable partial views are acceptable.
Hosts call install_config at startup:
install_config(
options,
max_cache_entries,
max_cache_bytes,
ccr_ttl_secs,
disk_tier_root,
);This installs:
- router and compressor options
- CCR memory limits
- CCR TTL
- optional CCR disk tier
Use configure(options) only when CCR limits and disk-tier settings are handled
elsewhere.
Plain text compression is host-provided:
tinyjuice::ml::configure_callback(Some(callback));The callback receives the text and CompressOptions, then returns
Result<Option<String>, String>. Returning None, returning text that does not
shrink, or returning an error makes the ML compressor decline without failing the
agent loop.
Hosts can install:
tinyjuice::savings::configure_recorder(Some(recorder));The recorder receives:
- content kind
- compressor kind
- estimated original tokens
- estimated compacted tokens
TinyJuice uses a rough character-based token estimate because it runs before a provider call. Model pricing and dashboard persistence remain host policy.
OpenHumanCompressionContext currently carries:
conversation_idmodel
This type is intentionally small. Do not add runtime dependencies to the core crate without a feature or adapter boundary.
Any host that shows CCR footers to an agent must provide a callable recovery tool:
- canonical name:
tokenjuice_retrieve - legacy alias:
retrieve_tool_output
The tool should return exact original content for a token. Its output must not be re-compacted.
- Feed raw tool output into TinyJuice only after host credential scrubbing.
- Keep compaction stats, but do not persist raw output in analytics records.
- Treat
CompactionStats.rule_idas a compressor/rule label, not a proof of semantic quality. - If a coding workflow fails because a partial view hid relevant data, switch
that agent or tool to
LightorOffbefore changing compressors globally.
Token compression for agent context.
Getting started
Concepts
Modules
Agent docs