AdaptiveWindowing

org.llm4s.agent.PruningStrategy.AdaptiveWindowing
See theAdaptiveWindowing companion object
final case class AdaptiveWindowing extends PruningStrategy

Adaptive windowing strategy that automatically determines the best context window size based on the model's context size and pricing information.

This strategy optimizes for cost-quality balance:

  • Uses tier-appropriate percentage of model's context window (reserves space for outputs)
  • Adjusts ratio based on model size (larger models use larger windows)
  • Can optionally use cost-sensitive tuning

The window is a token limit like maxTokens: with both set, the smaller applies, and maxMessages applies as well. The turns kept past the window are ContextWindowConfig.minRecentTurns.

Model tiers and window ratios:

  • Small (≤32K): 60% window to reduce costs
  • Medium (32K-100K): 70% balanced cost/quality
  • Large (100K-200K): 75% for more complex context
  • Extra large (>200K): 80% very generous window

Value parameters

contextWindowSize

The model's actual context window in tokens

costSensitivity

How aggressively to optimize for cost (0.0-1.0, default: 0.5) 0.0 = maximize quality, 1.0 = minimize cost

inputCostPerToken

Optional cost per input token (enables cost optimization)

outputCostPerToken

Optional cost per output token

Attributes

Companion
object
Source
ContextWindowConfig.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

Calculate the optimal token window based on model capabilities and costs. Returns the safe upper bound for conversation tokens.

Calculate the optimal token window based on model capabilities and costs. Returns the safe upper bound for conversation tokens.

Attributes

Source
ContextWindowConfig.scala

Get a human-readable explanation of the calculated window.

Get a human-readable explanation of the calculated window.

Attributes

Source
ContextWindowConfig.scala
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
Source
ContextWindowConfig.scala

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product