Context compaction
Compaction lets a long conversation continue by replacing older history with a shorter handoff.
Automatic and manual compaction
fx compacts automatically when a model request reaches 80% of its usable input window, then continues the same prompt. The usable window excludes tokens reserved for the model's response.
If the provider reports a context overflow before returning text or a tool call, fx compacts and retries once.
Run /compact between prompts to compact immediately:
/compactThis works below the automatic threshold and does not start another prompt. With no history to compact, fx makes no model request.
What fx keeps
fx keeps recent history without summarizing it, targeting 5% of the usable input window. It only cuts between complete tool steps, keeping each tool call with its result.
For older history, fx keeps the original user prompts in order when they fit and summarizes the assistant's work around them. If the user prompts alone exceed the budget, it summarizes the oldest ones. Handles for retained tool results stay available after compaction.
The handoff is capped at 10% of the usable window. Later compactions include the previous handoff so earlier context can carry forward.
Requests and saved history
fx creates the handoff with a separate, tool-free request to the current session model. Large histories may require more than one request. These requests count toward session usage and may add provider cost. See Usage and costs.
Compaction does not delete the original conversation; it remains available in Full detail. fx switches to the compacted context only after saving its checkpoint. If that fails, it keeps the previous context.