Overview & result
Before selected Pi LLM calls, this extension groups messages with their tool results, reuses prior judgments and asks Jev one yes/no relevance question for each new unit. Code removes units judged unnecessary while always keeping system messages and the latest request.
From the original post
A [pi](https://pi.dev) extension that curates the context sent to the LLM before each call — using **TypeSafe AI's Jev model** to decide which context is actually needed.
How Jev fits in the loop
- Group assistant tool calls and their results into atomic context units.
- Send only new units to Jev as parallel Noul yes/no questions in one request.
- Apply the keep/remove decision to the per-call context, caching each judgment by content fingerprint.
How to reproduce
- Install the package in Pi and provide a TypeSafe API key; without a key it is a no-op.
- Run a session past the default 8,000-token floor and inspect the extension's removed-unit and cost commands.
- Check that system messages, the latest request and uncertain Jev answers remain in context.
Why this build matters
A concrete context-pruning pattern that keeps Jev's role bounded and exposes the risk of permanent removal.
Limitations
- A false removal can hide a subtle dependency from later model calls; the threshold needs local testing.
- Removed units are permanently omitted from later model context, although a display-only session record remains inspectable.
- On API errors or missing credentials the extension passes context through unchanged.