shipwithjev

Catalog / Agents & browsers

0199GitHub

pi-jev-compaction

Automatic context clearing for Pi, without losing the conversation.

nourhelmi/pi-jev-compactionREADME ↗
# pi-jev-compaction

**Keep the conversation. Clear stale tool output. Get the original back without running the command again.**

An automatic [Pi](https://pi.dev) extension powered by [TypeSafe Jev](https://typesafe.ai). Jev scores older tool outputs; Pi stops sending the ones you no longer need. Your original session messages stay intact.

No extra agent. No summary model. No runtime dependencies beyond Pi.

## Install

```sh
pi install git:github.com/nourhelmi/pi-jev-compaction
export TYPESAFE_API_KEY="your-typesafe-api-key"
pi
```

Get a key from [TypeSafe](https://typesafe.ai). Set it in the environment where you launch Pi. Already running Pi? `/reload` reloads the extension, but a newly exported shell variable requires restarting Pi from that shell.

That's it. Clearing runs automatically. `/jev-status` shows its configuration and last result.

```sh
pi remove git:github.com/nourhelmi/pi-jev-compaction
```

Requires Node.js **22.19+**. Tested against Pi **0.85.1**. Works with models running inside Pi, not with standalone Claude Code or Codex CLI sessions.

## How it works

1. After a tool turn reaches **65% of the model's context window**, inspect older successful text outputs.
2. Protect the latest **12k estimated tokens**, including complete parallel tool batches.
3. Ask Jev about up to **16 large outputs**, sending bounded conversation, argument, and result excerpts in one request.
4. Clear an output only when its estimated probability of still being needed is below **0.25**.
5. Replace its model-facing body with a stable marker. Keep the tool call, message order, metadata, and original evidence.

Example marker:

```text
[pi-jev: older tool output cleared from context; original retained in this session.
Retrieve with jev_read({"ref":"…"}). Do not rerun a side

Also filed under Agents & browsers

  1. 0295

    Flight search with Browser Use

    Breaking: Browser Use + Jev = Ultrafast ⚡ Findings flights took 7s and cost only $0.0039 🤯 > new action space every step > DOM state space > small LLM fallback to type (this video is at 1x speed btw) Built a tiny open source browser agent. try it below ↓

    @gregpr07 · Agents & browsers · ~$0.004 · ~7 s

  2. 0500

    Jev: AI Decisions as a Typed Function Call | StackToHeap

    # Jev: AI Decisions as a Typed Function Call What I learned using TypeSafe's Jev for code review, and why its more surprising uses are browser control and generative UI.…

    stacktoheap.com · Agents & browsers

  3. 0319

    x-scanner

    Chrome extension that labels every post you scroll past on X with six typed questions per post, and counts what it costs in the corner.

    oso95 · Agents & browsers

  4. 0318

    Vibe Check for X

    Chrome extension that scores draft posts and reply context before posting; optional media descriptions come from a separate vision model.

    RafalWilinski · Agents & browsers