# hermes-jev-compact

Smarter context compression for Hermes Agent (opt-in `context.engine: jev`):
stale tool call/result units are scored by TypeSafe Jev (keep / truncate /
drop by calibrated probability) instead of being pruned by age alone.
Any failure falls back to the built-in deterministic prune.

## install

```bash
/path/to/hermes-python -m pip install hermes-jev-compact
hermes plugins enable hermes-jev-compact --no-allow-tool-override
```

Then set `context.engine: jev` and `/reset`. `compressor` bypasses plugins;
`jev` only activates when named. Disable with
`hermes config set context.engine compressor` + `/reset`.

## requires

- a System One endpoint at `base_url` (default `https://api.typesafe.ai/v1`;
  key from https://console.typesafe.ai/settings/keys)
- client key in `~/.hermes/.env` under `api_key_env` (default `TYPESAFE_API_KEY`)

## settings

`plugins.entries.hermes-jev-compact.settings`: `base_url`, `api_key_env`,
`jev_model` (`jev-latest`), `keep_threshold` (0.5), `max_state_tokens` (25000),
`max_request_tokens` (30000), `truncate_head_chars` (300), `request_timeout_s`
(30), `min_result_chars` (8000).

## behavior

Overrides only `_prune_old_tool_results` on the built-in compressor (the hot
proactive path bypasses Jev — deterministic/no-LLM contract kept). Candidates
are paired call+result units before the prune boundary; Jev scores two `noul`
questions per unit against the fitted transcript; output must pass structural
validity AND shrink ≥25% or the built-in prune runs instead. Counters
`jev_calls` / `jev_pruned_units` / `jev_fallbacks` on the compressor.
