Skip to content

Compact long sessions into fresh context windows - #471

Open
fazxes wants to merge 18 commits into
mainfrom
fazxes/hybrid-context-compaction
Open

Compact long sessions into fresh context windows#471
fazxes wants to merge 18 commits into
mainfrom
fazxes/hybrid-context-compaction

Conversation

@fazxes

@fazxes fazxes commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Compact model context at 80% of usable input and continue from a checkpoint capped by the 10% session target.
  • Make /compact install the same checkpoint and wait for the next prompt.
  • Preserve canonical history, provider-valid recent turns, and retrievable tool results across repeated compaction, restart, and resume.
  • Keep completed tool effects in a runtime-owned authoritative ledger so continuation does not reinterpret or repeat them.
  • Limit compactor models to non-authoritative conversation summaries, using capacity-based chunks only when required.
  • Route compaction through the active Gateway, Codex, or Grok provider, then resume the original working model.

@fazxes fazxes added the type: improvement Improves existing user-facing behavior label Aug 27, 2026
@fazxes fazxes changed the title Compact model context by request pressure Compact long sessions into fresh context windows Aug 28, 2026
@fazxes
fazxes marked this pull request as ready for review August 28, 2026 06:43
fazxes added 8 commits August 30, 2026 18:20
Measure complete provider requests before removing settled tool result bodies. Preserve retrievable output and keep manual and no-save behavior explicit.
Use the active model to create bounded, tool-free handoffs for automatic and manual compaction. Preserve canonical history and result handles across restart and resume.
Skip automatic compaction when the current user prompt alone exceeds the compacted window. Leave the exact request unchanged for provider capacity handling.
Teach the existing 4 MiB permission fixtures to answer the handoff request before the final model response. Keep their approval and exact-byte assertions unchanged.
Replace selected-model Markdown summaries with a dedicated structured compactor. Preserve complete canonical history, exact recent context, result evidence, and verified operation lineage across repeated compaction and restart. Keep automatic continuation on the selected model and manual compaction idle after installation.
@fazxes
fazxes force-pushed the fazxes/hybrid-context-compaction branch from c76b352 to 6bc8ea8 Compare August 31, 2026 00:44
Use the portable C allocator for concurrent block work, bound oversized tool-call evidence by byte count and SHA-256, and update maximum-write fixtures to the typed checkpoint contract.
iamken1204 added a commit to iamken1204/fx that referenced this pull request Aug 31, 2026
kfx/specs/context-budget.md holds where the 2026-08-29 session's input
tokens went, the four levers ranked by measured savings, the comparison
with Claude Code, Codex CLI, and Pi, and what was deliberately left alone:
the terminal schema, the repo AGENTS.md, and a child-only step ceiling
that was built and removed because fx ends a capped turn with no final
answer.

FORK.md gains the three inventory rows, the recommended setup with
FX_KEEP_RECENT_RESULTS, FX_SKILL_SOURCES, and the max_tool_result_bytes
setting, two post-rebase verification steps, and the note that the
eviction projection must stay on the suffix argument when upstream PR vercel-labs#471
or the context-retention patches move prompt assembly.

Claude-Session: https://claude.ai/code/session_01NJcKHYnFdSx9edVacBHEjn
iamken1204 added a commit to iamken1204/fx that referenced this pull request Aug 31, 2026
kfx/specs/context-budget.md holds where the 2026-08-29 session's input
tokens went, the four levers ranked by measured savings, the comparison
with Claude Code, Codex CLI, and Pi, and what was deliberately left alone:
the terminal schema, the repo AGENTS.md, and a child-only step ceiling
that was built and removed because fx ends a capped turn with no final
answer.

FORK.md gains the three inventory rows, the recommended setup with
FX_KEEP_RECENT_RESULTS, FX_SKILL_SOURCES, and the max_tool_result_bytes
setting, two post-rebase verification steps, and the note that the
eviction projection must stay on the suffix argument when upstream PR vercel-labs#471
or the context-retention patches move prompt assembly.

Claude-Session: https://claude.ai/code/session_01NJcKHYnFdSx9edVacBHEjn
fazxes added 9 commits August 31, 2026 13:22
Use provider-local compaction models and credentials across TUI, ask, ACP, and subagents. Keep typed provenance validation compatible with Gateway, Codex, and Grok responses.
Keep tool execution truth in a runtime-owned ledger and limit compactor models to conversation summary prose. Partition summary work by capacity and preserve provider-valid history tails.
Expect the model catalog lookup required to resolve compaction capacity while preserving the no-Vision text-only path.
Preserve complete turn boundaries, calibrate automatic thresholds from provider usage, and carry only the active context window into repeated compaction.
Use a dedicated worker task for manual compaction and share one transaction between manual and automatic paths. Keep authoritative state limited to structured operation records and remove obsolete structured-output plumbing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: improvement Improves existing user-facing behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant