Skip to documentation
Documentation navigation

Documentation navigation

Documentation / guides

Conservative estimates

Use heuristic counts only when policy explicitly admits conservative quality.

developer

CountQualityHeuristicEstimate is an explicit quality, not a synonym for an exact tokenizer. Admission policy must decide whether that quality is safe for the model’s context limit.

Quality

CounterCapability.Quality and ContextCount.Quality must agree. A counter that returns a heuristic count while declaring exact quality is rejected by ContextCounterFunc. A policy requiring exact quality must reject the result; there is no automatic promotion or silent fallback.

QualityMeaningExact-only policy
CountQualityExactProviderendpoint-owned countadmitted
CountQualityExactLocallocal tokenizer countadmitted
CountQualityHeuristicEstimatebounded estimaterejected
CountQualityUnknownno trust claiminvalid

Estimate

The bundled Estimator returns a heuristic estimate from the selected dialect’s complete encoded request. Its capability declares local transport, no retention, a revision string, and heuristic quality. Consumers that admit it should apply their own safety margin before comparing with a limit.

Source and proof

Run go test ./contextcount.

← back to documentation