Skip to content

Provider-neutral session compaction + opt-in token_usage auto-compact policy - #246

Closed
0thernet wants to merge 4 commits into
claude/oompa-v0.8.0from
devin/session-compaction
Closed

0thernet wants to merge 4 commits into
claude/oompa-v0.8.0from
devin/session-compaction

Conversation

@0thernet

Copy link
Copy Markdown
Member

Summary

  • Phase 3 (5501d83a): provider-neutral session.compact — Codex dispatches thread/compact/start through the pinned app-server client, Claude writes /compact on the stream-json input; both reduce to one durable compaction timeline event (outcome/trigger/strategy/token fields only, no text), receipted before dispatch, idempotent by key, refused mid-turn, and reconciled against the event stream without replay.
  • Phase 4 (604e435c): opt-in per-session auto-compaction. Schema v61 adds session_compact_policies (STRICT, cascade FK, default-off seed trigger, monotonic-revision transition guard, delete guard, backfill). session.compact-policy get/set exposes it with revision CAS; CLI grammar oompa session compact-policy <session> on|off [--trigger-tokens 20000..4000000] [--min-interval-ms 30000..86400000] [--expected-revision n]. After a durable token_usage event, evaluateAutoCompact (pure, total, property-tested) can schedule session.compact under the session serializer with trigger: "policy" and a deterministic per-bucket idempotency key — exactly one dispatch per usage bucket; the serialized closure re-evaluates fresh policy/interval/turn state before dispatch.
  • Defaults: enabled: false, triggerTokens: 250_000, minIntervalMs: 300_000 — compacting at 250k instead of provider-default ~1M roughly halves the average context cost.
  • Docs: docs/providers/codex.md (new) and docs/providers/claude.md record the verified provider compaction contracts; site/content.ts command reference matches CLI help; plan kb/plans/session-compaction.md is complete with full evidence.

Test plan

  • bun run check — every step green on the final tree: install-pins, effect-architecture, security-primitives (baseline refreshed for two reviewed new call sites), eslint, tsc; scripts 1795/1795, local-efficiency plugin 119/119, cloud-efficiency plugin 36/36, bun test ./src 6114 pass (4 five-second timeouts from machine load ~20, each verified green in isolation), convex 329/329, site 176/176, app 625/625; build:site -- --check, build:app, build clean; check:package green on a governed-ref checkout (history scan + refreshed 225-entry release inventory).
  • Independent review round: no authority/recovery findings; four hardening fixes landed (dispatch-time re-evaluation, CONFLICT suppression noise, delete guard, fast-check properties).
  • Live-provider resume of custom compacted Codex records remains quota-blocked (noted in plan).

Note: this targets claude/oompa-v0.8.0, the line the worktree was cut from. When that line next converges to main (currently itself at schema 61 via #225), this migration renumbers to the next free version.

Generated with Devin

0thernet and others added 4 commits September 16, 2026 15:48
Codex dispatches thread/compact/start through the pinned app-server
client and Claude sends provider-native /compact between turns, both
behind a durable session.compact command bound to the session's exact
authority generation. Provider facts project to one bounded compaction
timeline event (outcome, trigger, strategy, token counts only), and an
indeterminate dispatch reconciles against the retained event stream
rather than replaying.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
A durable per-session session_compact_policies row (schema v61, STRICT
table, cascade FK, default-off seed trigger, monotonic-revision
transition guard, delete guard, backfill) backs the new
session.compact-policy get/set contract and CLI surface with revision
CAS. After a token_usage event is durable, the pure evaluateAutoCompact
decision (trigger capped by model context window, in-flight turn and
minimum-interval suppression) can schedule the existing durable
session.compact under the session serializer with trigger "policy" and
a deterministic per-usage-bucket idempotency key, so a second
observation in the same bucket replays the command instead of
dispatching twice. The serialized closure re-evaluates fresh policy,
interval, and turn state before dispatch, and beginEffect re-fences the
turn check so a refused attempt stays prepared and retryable without
burning the key or the interval budget.

Docs record the verified provider compaction contract for Codex and
Claude, the public command reference matches CLI help, and the reviewed
release inventory and public-text allowlist were refreshed for the new
shipped module and main's new public dependencies.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
oompa Ready Ready Preview Sep 17, 2026 6:41am UTC
1 Skipped Deployment
Project Deployment Actions Updated
oompa-app Ignored Ignored Sep 17, 2026 6:41am UTC

Request Review

@0thernet

Copy link
Copy Markdown
Member Author

Superseded by #252: the same feature ported onto main (the session_compact_policies migration renumbered v61→v62 because main's schema 61 is the Devin readmission from #225, plus Devin /compact support added). This branch remains the release-line variant for claude/oompa-v0.8.0 if that line ever needs it.

@0thernet 0thernet closed this Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant