Condukt.Compactor.Sliding (Condukt v3.0.0)

Copy Markdown View Source

Keeps the last N messages of the conversation.

Tool results whose originating tool call has been dropped are also removed, since most providers reject orphaned tool results.

Options

  • :keep - number of trailing messages to retain (default: 20).

When a native session compacts because the provider rejected a request as too long, it passes context_overflow: true. Sliding then keeps half as many messages as it otherwise would (half of :keep, or half of a shorter history), and at least one. That window starts before a batch of tool results rather than inside it, so recent tool calls keep their results.

Example

MyApp.Agent.start_link(
  compactor: {Condukt.Compactor.Sliding, keep: 40}
)