← All toolsLive demo

Context Compaction

Watch Jev shrink an agent's context in real time — KEEP the essential, TRUNCATE the long, DROP the noise — one typed decision per step. No key, just press compact.

A real agent trace — Jev calls KEEP / TRUNCATE / DROP on every step so the context fits, without losing the thread.
0/14steps
0.0selapsed
0/sdecisions/sec
Jev cost
Context
8,465/8,465 tok
compacting… 0% so faressential goals, findings & results preserved
systemSystem prompt: you are a coding agent that refactors code and fixes bugs safely.180t
userGoal: move our login to the new session API and fix the logout bug.40t
assistantPlan: read auth/session.js, locate the logout bug, apply the fix, run the tests.60t
toolread_file auth/session.js → 412 lines of source returned (full file dump).2,600t
assistantFound it — clearSession() never awaits the DB delete, so logout races the redirect.45t
toolgrep 'clearSession' → 28 matches across 14 files (full list).640t
toolnpm install log — 214 lines of dependency resolution output.1,800t
assistantRunning the test suite to see the current state.25t
tooltest run 1 → 140/142 pass, 2 fail on session expiry (118-line log).1,500t
userAlso make sure it still works on mobile Safari.30t
assistantApplied fix: await the DB delete and set session maxAge to 7 days.55t
tooltest run 2 → 142/142 pass (full log).1,400t
assistantVerified logout on mobile Safari — the session clears correctly.40t
assistantDone: logout awaits the delete, maxAge is set, mobile verified.50t

This is exactly what agents do to survive long tasks — one typed Jev call per step. See all live demos →

A demo of the decision pattern — real compaction also keeps recent turns and pins the system prompt. Token counts are illustrative.

Get an API key →Ready-made APIs

How it works

Long-running agents blow past the context window: tool dumps, install logs and redundant listings pile up until the goal scrolls off the top. Compaction fixes that by deciding, step by step, what to keep in full, what to shorten to a summary, and what to drop. Here every step of a real agent trace is one Jev call returning a typed KEEP / TRUNCATE / DROP — streamed in live while the token bar shows the context collapsing.

The essential things — the user's goal, the key finding, the change that was applied, the final result — stay in full. The noise gets cut. That is exactly the pattern agents use to survive tasks that run for hours.

Build it into your agent

With a hosted key the same Jev call runs over your own message history before each turn: a typed decision per step at $0.42/M input tokens, in milliseconds, with no malformed output. Pair it with a rule to always pin the system prompt and keep the last few turns, and you have compaction that keeps agents on-task without a summarizer model or a brittle prompt.

FAQ

Does Jev actually decide per step?

Yes — every step of the trace is an independent Jev call that returns a typed KEEP, TRUNCATE or DROP plus whether the step is essential. The verdicts stream in live and the token bar updates as they land.

Is the token count real?

The per-step weights are illustrative so the shrink is easy to see, but the decision each step gets is a real, live Jev call. In your own agent you'd compact against the actual token counts.

Is it free? Can I run my own trace?

Free, no key — a rate-limited call to the live Jev API. To compact your own agent's context at scale, wire the same call into your loop with a hosted key.

More: Model Router demo · Ask 100 Personas · All Jev tools · Jev API docs

Context Compaction — watch AI shrink an agent's context · Jev by TypeSafe AI