
Security News
Deno Goes the Way of the Dinosaur
Cloudflare is acquiring Deno’s team, which will provide another year of bug fixes and security updates before ending support for the runtime.
pi-codex-compaction
Advanced tools
Keep Pi sessions flowing with automatic server-side compaction on public OpenAI Responses.
Keep long Pi sessions flowing with automatic server-side compaction inside ordinary OpenAI Responses requests. The server can emit an encrypted checkpoint and continue inference without Pi stopping for a separate summary request.
openai GPT-5/GPT-6 requests./server-compaction off, manual /compact, and Pi's standard compactor
as recovery options.Requires Pi 1.1.0 or later. The package name is unchanged, but the legacy
openai-codex provider is no longer supported.
pi install npm:pi-codex-compaction
For local development:
pi install /path/to/pi-mono/packages/pi-codex-compaction
Or load it for one run:
pi -e /path/to/pi-mono/packages/pi-codex-compaction
Select a GPT-5/GPT-6 model on provider openai, API openai-responses, at
https://api.openai.com/v1. No enable command is needed. A previously saved
off setting on the current session branch remains respected.
Load this package after extensions that transform provider requests. Pi orders handlers by extension load order. The compatibility guard cannot prevent a later extension from adding incompatible fields.
/server-compaction status
/server-compaction off
/server-compaction on
/server-compaction on 100000
Commands persist the mode and optional token threshold on the current session
branch, not in global or project settings. on without a number uses the startup
threshold, or the default when none was supplied.
--server-compaction defaults to true.
--server-compaction-threshold 100000 supplies a startup threshold.
Saved command settings take precedence.
The default threshold is 60% of Pi's local trigger
(contextWindow - reserveTokens), including per-model reserve overrides. This
is a headroom heuristic, not an OpenAI-prescribed optimal threshold. Explicit
thresholds must be integers of at least 1,000 and below Pi's local trigger.
Invalid or too-late thresholds leave ordinary inference unchanged.
Very small thresholds can compact repeatedly within one response and increase latency and token use. Do not use the 1,000-token protocol-test threshold for ordinary long sessions.
The extension adds
context_management: [{ type: "compaction", compact_threshold: ... }],
store: false, and stream: true to eligible ordinary requests. It does not
construct a separate compaction request or reconstruct tool declarations.
Pi's actual request retains grammar tools, hidden loadouts, reasoning options,
Fast settings, and declarations carried through additional_tools.
Text streams normally. After successful completion, the extension commits a
Pi compaction entry at turn_end, before the next assistant response. It stores
the latest encrypted checkpoint and the exact provider output following it.
On subsequent requests, it replaces the readable fallback and the retained
assistant's serialized items with that checkpoint and output suffix. Later
tool results and messages remain.
The original transcript stays in the session file. Reload and tree navigation use the selected branch, not a global cache. Turning the mode off stops requesting new checkpoints but still replays a compatible saved checkpoint while the extension remains loaded.
Successful adoption avoids a separate Pi compaction lifecycle, including between
tool continuations. It does not promise zero server-side delay or concurrent
inference during the server's compaction pass. It does not set background: true.
Authentication stays with Pi: /login openai with Sign in with ChatGPT
uses plan quota; an OpenAI API key uses separate API billing. Neither path
falls back to the other. This is automatic context_management in ordinary
/responses, not the standalone /responses/compact API or the removed private
RemoteCompactionV2 protocol.
| Route | Behavior |
|---|---|
openai + openai-responses, official endpoint, GPT-5/GPT-6 | Automatic compaction on by default; server/model availability still applies |
| Same route with ChatGPT sign-in | Live checkpoint/replay verified with gpt-6-astra |
| Same route with an API key | Mocked contract coverage; no live billing test |
Legacy openai-codex, custom endpoints, other providers, routed model mismatch | Left unchanged; no compaction or auth hooks for those routes |
Virtual-model selections are also ineligible, including when their physical dispatch returns to the same public OpenAI model. Pi 1.1.0 request hooks expose the selected virtual model, not a complete physical request/auth identity. Existing checkpoints use their bounded readable fallback rather than opaque replay. Pi's ordinary routed context-limit checks and standard compaction remain available; no checkpoint identity is inferred from the payload's model name.
GPT-6.1 Sol matches the GPT-6 candidate guard, but the existing live replay evidence is Astra-only. Model eligibility is not proof of account availability. No default model is changed. See the provider migration assessment for the separate reasoning-update limitation.
configuration_update, compaction_trigger, an existing
context_management, stateful continuation, truncation, background processing,
or enabled multi-agent mode are not opted in./compact,
including custom instructions, uses Pi's standard summarizer./server-compaction on or session reload. The extension does
not issue an extra paid retry or switch credentials; Pi owns its own retries.Legacy RemoteCompactionV2 requests, chatgpt.com/backend-api transport, beta
headers, the temporary pi-ai/compat serializer, old transport helper exports,
and the pi-codex-compaction:tools:v1 / :request:v1 event-bus contracts have
been removed. Fast and grammar integrations now use the ordinary Pi pipeline.
Existing legacy session files are not modified or deleted. Old encrypted
checkpoints are not migrated or replayed across providers; their readable
fallback remains available. Use compatible package versions together.
pi-fast and pi-codex-tools still support their own legacy-provider use cases;
this change removes only their obsolete direct-compaction adapters.
pi-openai-reasoning remains a legacy-provider-only extension. This package
does not migrate it or enable its reasoning-update feature on the public route.
Automatic compaction and histories containing configuration_update are
incompatible in the public API.
Tests use real Pi sessions with mocked transport to cover effective loadouts, streaming, tool continuations, checkpoint ordering, branches, reloads, cancellation, credential changes, context edits, default-on behavior, and the standard compaction safety net.
A small live subscription test with gpt-6-astra verified checkpoint adoption,
replay, and synthetic fact recall. At a deliberately low 1,000-token threshold,
automatic mode used two requests versus four for standard Pi. The first answer
completed sooner, but overall elapsed time and reported token use were higher.
That protocol test did not measure long-session streaming continuity and does
not establish cost or latency savings.
In a checkout, tests/AUTOMATIC_BENCHMARK.md contains the measurements, limits,
and Codex source comparison. tests/benchmark-automatic.mjs is an explicitly
gated live test and is not run by npm test. Live testing requires approval to
consume usage; use synthetic text, not private session history or images.
npm run -w packages/pi-codex-compaction check
npm test -w packages/pi-codex-compaction
npm run -w packages/pi-codex-compaction pack:dry-run
For an approved TUI smoke test, cross the configured threshold in a synthetic
session, then check facts from earlier turns and a tool continuation. Check replay
after /reload, mode-off, and branch navigation. Successful adoption should
not start Pi's separate compaction lifecycle.
References:
Install telemetry is best-effort, once per version. Disable it with
PI_OFFLINE=1, PI_TELEMETRY=0, or enableInstallTelemetry: false.
FAQs
Keep Pi sessions flowing with automatic server-side compaction on public OpenAI Responses.
The npm package pi-codex-compaction receives a total of 0 weekly downloads. As such, pi-codex-compaction popularity was classified as not popular.
We found that pi-codex-compaction demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
Cloudflare is acquiring Deno’s team, which will provide another year of bug fixes and security updates before ending support for the runtime.

Security News
Anthropic’s free OSS Scanner uses Mythos and other Claude models to find open source vulnerabilities and send maintainers reports with proposed fixes.

Security News
On Front Lines’ Early Adopters: CISO podcast, Andrew Becherer shares lessons from Datadog, weighs the long-term costs of AI-built tools, and explains how founders can actually gain a CISO’s trust.