-
Notifications
You must be signed in to change notification settings - Fork 1
Agent Guide
Steven Enamakel edited this page Jul 5, 2026
·
1 revision
This page is a compact, machine-oriented reference for agents modifying or using TinyJuice.
Use this for tool output:
compact_tool_output_with_policy(tool_name, arguments, output, exit_code, profile).awaitUse this for arbitrary content:
compress_content(content, Some(hint), &opts).awaitUse this for command-output reducer tests:
reduce_execution_with_rules(input, &load_builtin_rules(), &ReduceOptions::default())- Do not log raw prompts, raw context, raw tool output, or credentials.
- Do not compact output from
tokenjuice_retrieveorretrieve_tool_output. - Do not claim compression percentages without benchmark fixtures.
- Do not add OpenHuman runtime dependencies to core modules.
- Do not make a lossy compressor return
reformatted. - Do not append CCR footers inside a compressor.
- Do not blindly head/tail truncate non-command domain data.
- Add a module under
src/compressors/. - Implement
compressors::Compressor. - Return
Nonewhen unsupported or not smaller. - Return
CompressOutput::lossywhen data is dropped. - Return
CompressOutput::reformattedonly when every value is preserved. - Register the static compressor in
src/compressors/mod.rs. - Add or update content detection in
src/detect/if needed. - Add focused unit tests and an e2e test when CCR behavior changes.
- Update this wiki and README if public behavior changes.
- Create a JSON rule in the desired layer:
- built-in:
src/vendor/rules/ - user:
~/.config/tokenjuice/rules/ - project:
.tokenjuice/rules/
- built-in:
- Include match criteria with enough specificity.
- Use filters, transforms, counters, and summarize settings.
- Add a fixture in
tests/fixtures/*.fixture.json. - Run
cargo test.
Check in order:
- Was
router_enabledtrue? - Was the payload below
min_bytes_to_compress? - Did detection choose the expected
ContentKind? - Was the per-kind compressor enabled?
- Did the compressor return
None? - Was the compacted output actually smaller?
- Was it lossy with CCR disabled?
- Was it lossy below
ccr_min_tokens? - Could CCR retain the original?
- Was the agent profile
LightorOff?
Check:
- Does output contain a parseable marker?
- Is the token a fixed-shape hex token?
- Is the memory store still within TTL?
- Was a disk tier configured?
- Was the original too large for memory and disk disabled?
- Was the output from a recovery tool accidentally re-compacted?
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test
cargo bench
cargo run --example passthroughsrc/lib.rs public exports
src/types.rs router, rule, and profile types
src/compress.rs router
src/compressors/ compressors
src/cache/ CCR
src/rules/ rule loader/compiler/builtins
src/reduce.rs reduction pipeline
src/tool_integration.rs host tool adapter
src/ml.rs host ML callback
src/savings.rs host savings callback
tests/e2e_tool_output.rs profile + CCR end-to-end checks
tests/fixtures.rs rule fixtures
benches/compression.rs hot-path throughput benches
Use:
- "content-aware compaction"
- "recoverable partial view"
- "exact original via
tokenjuice_retrieve" - "estimated token savings"
- "benchmark fixtures required before percentage claims"
Avoid:
- "guaranteed 90% savings"
- "semantic compression is always safe"
- "lossless" when rows, lines, markup, context, or bodies are omitted
Token compression for agent context.
Getting started
Concepts
Modules
Agent docs