Skip to content

feat: add /compact and automatic context compaction - #618

Merged
Ooooze merged 1 commit into
mainfrom
codex/context-compaction
Oct 7, 2026
Merged

Ooooze merged 1 commit into
mainfrom
codex/context-compaction

Conversation

@Ooooze

@Ooooze Ooooze commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Long conversations currently lose older context through mechanical history trimming. Add manual and automatic compaction that replaces the older portion of model input with a persisted summary while retaining the complete append-only session transcript.

  • Add /compact and /compact show, HTTP session compaction endpoints, and correlated NDJSON sidecar operations. TUI shows queued/running status, elapsed time, part progress, cancellation, and context usage after persistence.
  • Share checkpoint/history projection across flat prompts, native messages, token budgeting, and pure preview. Run manual requests at safe step boundaries through session controls, preserve tool/result pairs and turn ownership, and retain bounded trimming/overflow recovery on failure.
  • Use the session's current model and provider route without tools. Send the complete summary request in one call when it fits the model window; split only when necessary. Both the default call timeout and overall ceiling are 600,000 ms (10 minutes).
  • Repeat verbatim user request anchors and source attribution when merging large inputs, and save a checkpoint only after all parts complete successfully. Summarization usage is accounted separately.

Validation

  • 48 focused runtime/config/HTTP/sidecar/TUI integration tests passed. The TUI tests run against the real runtime with scripted model responses.
  • imports:check, imports:self-test, lint, typecheck:tests, docs:check, and build passed. Import/documentation checks were repeated after rebasing onto current main; the rebase changed only the existing base documentation and ignore rules.
  • Latest full Vitest run: 13,526 passed, 4 skipped, 1 failed. The failure is the unchanged timing-sensitive download-worker > ends cancelled when the signal fires, with the partial kept for resume test, which expected ab but observed an empty partial file. All 17 tests in that file passed on the separate rerun. The full suite is not being reported as green.
  • Real local-model runs on disposable synthetic history exercised a large single request and repeated compactions, retained the original transcript, and preserved key constraints and a recorded failed test. The large single request completed in about 4m36s, beyond the former two-minute timeout.

Remaining limits

The local model also produced unsupported interpretations in some synthetic summaries; semantic fidelity is not fully validated. The cloud route and continuation through real task execution after repeated compaction were not exercised. Desktop UI changes, channel commands, and durable memory are outside this change.

@Ooooze
Ooooze merged commit dd944dd into main Oct 7, 2026
2 checks passed
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