Skip to content

Jev Semantic Context Gate

github-actions[bot] edited this page Sep 26, 2026 · 3 revisions

Jev Semantic Context Gate

Token Terminator 0.8.0 added the optional semantic context gate backed by TypeSafe Jev. v0.8.1 added Hermes memory-provider awareness; v0.8.2 supports both OpenRouter and direct TypeSafe transport.

It is not a replacement mode. The normal Token Terminator pipeline still runs first.

host assembles provider request
        ↓
SkillGate (when applicable)
        ↓
request compiler
        ↓
deterministic context compactor
        ↓
optional Jev semantic gate
        ↓
strict character/token acceptance
        ↓
provider

With Jev disabled, the pipeline behaves as before.

What Jev does

After deterministic Token Terminator reduction, some prior natural-language conversation can still remain inline. Jev receives the current user request plus a bounded set of remaining prior plain-text user/assistant messages. On Hermes, <memory-context> background injected by memory providers such as Hindsight is separated from the user's actual words and may be scored as its own candidate. Jev answers two typed noul questions per candidate in one batched System One request:

  1. relevance — would this prior message materially help answer the current request?
  2. guard — does it contain an instruction, constraint, preference, commitment, exact value/name/code/quotation, or other detail whose omission could materially change the answer?

A message is eligible for compaction only when both probabilities are below the configured threshold.

Jev does not generate replacement prose. Token Terminator writes the exact original message to the local content-addressed vault and replaces it with a compact recovery receipt. This avoids paying tokens for a generated summary and preserves exact recovery.

What Jev never receives from this feature

The semantic gate excludes:

  • system messages;
  • developer messages;
  • tool messages and tool results;
  • messages carrying tool calls;
  • structured or multimodal message content;
  • oversized candidates beyond the configured safety cap.

The newest user message is sent as the query against which relevance is judged, but it is never itself a removal candidate.

Enable it

Jev is off by default. You need one provider key, not two.

OpenRouter is preferred automatically when its key is available:

export TOKEN_TERMINATOR_JEV=true
export OPENROUTER_API_KEY="..."

For a direct TypeSafe account:

export TOKEN_TERMINATOR_JEV=true
export TOKEN_TERMINATOR_JEV_PROVIDER=typesafe
export TYPESAFE_API_KEY="..."

The default TOKEN_TERMINATOR_JEV_PROVIDER=auto prefers OpenRouter if both keys happen to exist, otherwise it uses the available TypeSafe key. Set openrouter or typesafe explicitly to force the route.

The old TOKEN_TERMINATOR_JEV_API_KEY remains only as a temporary v0.8.0/v0.8.1 compatibility alias for direct TypeSafe access.

No API key belongs in the repository. Token Terminator does not persist or print it.

Defaults

Variable Default
TOKEN_TERMINATOR_JEV false
TOKEN_TERMINATOR_JEV_PROVIDER auto
TOKEN_TERMINATOR_JEV_MODEL provider default
TOKEN_TERMINATOR_JEV_TIMEOUT_MS 1500
TOKEN_TERMINATOR_JEV_RELEVANCE_THRESHOLD 0.15
TOKEN_TERMINATOR_JEV_MIN_MESSAGE_CHARS 600
TOKEN_TERMINATOR_JEV_MAX_CANDIDATES 12
TOKEN_TERMINATOR_JEV_MAX_CANDIDATE_CHARS 12000
TOKEN_TERMINATOR_JEV_MAX_STATE_CHARS 60000

The threshold is intentionally conservative. A candidate is removed only if both the relevance and guard probabilities fall below it.

Failure behavior

Every Jev failure is fail-open relative to the already-reduced Token Terminator request.

A timeout, HTTP error, malformed response, missing answer, vault failure, character expansion, or exact-token expansion simply skips the Jev reduction. It does not undo compiler, compactor, SkillGate, temporal, native, RTK, or vault work that already succeeded.

External-service boundary

Enabling Jev explicitly permits the bounded current user request, selected prior plain-text user/assistant candidates, and separately fenced Hermes <memory-context> background to be sent either through OpenRouter's Decisions API (which routes Jev to TypeSafe) or directly to TypeSafe. Keep TOKEN_TERMINATOR_JEV=false when that external transfer is not appropriate.

The exact removed content remains authoritative in Token Terminator's local vault. Jev supplies typed decisions; it never owns the evidence or the recovery path.

Clone this wiki locally