JuliusBrussee/caveman · error

cachebench: replay token summary overflow

Error message

cachebench: replay token summary overflow

What it means

Raised while accumulating provider usage tokens into the replay summary: adding a record's ProviderTotalInputTokens or ProviderOutputTokens to the running int64 totals would overflow (input > MaxInt64-summary.InputTokens, etc.). More than ~9.2e18 total tokens indicates corrupted counters rather than a real workload.

Solutions

  1. Inspect the provider usage payloads for absurd token counts (serialization or unit bugs)
  2. Cap or reject individual records whose counters exceed plausible request sizes
  3. Split the evidence into per-provider or per-batch summaries to keep totals in range
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cacheengine/cachebench/replay.go:295 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18). Data as JSON: /api/errors/d21cf69d1ea5b026. Report an issue: GitHub.

Appendix: source

Thrown at cacheengine/cachebench/replay.go:295

			group.summary.Successful++
			if record.QualityPassed {
				summary.QualityPassed++
				group.summary.QualityPassed++
			}
		} else {
			summary.Failed++
			group.summary.Failed++
		}
		if !record.TimingFaithful {
			summary.TimingFaithful = false
		}
		if record.TokenBasis != TokenProviderCounted {
			summary.InputBudgetClaimedProviderCounted = false
		}
		if record.ProviderUsageSHA256 != "" {
			input, output := int64(record.ProviderTotalInputTokens), int64(record.ProviderOutputTokens)
			if input > math.MaxInt64-summary.InputTokens || output > math.MaxInt64-summary.OutputTokens || input > math.MaxInt64-group.summary.InputTokens || output > math.MaxInt64-group.summary.OutputTokens {
				return ReplayEvidenceSummary{}, errors.New("cachebench: replay token summary overflow")
			}
			summary.InputTokens += input
			summary.OutputTokens += output
			group.summary.InputTokens += input
			group.summary.OutputTokens += output
		}
		if record.HTTPStatus > 0 {
			latencies = append(latencies, record.LatencyMilliseconds)
			group.latencies = append(group.latencies, record.LatencyMilliseconds)
		}
	}
	summary.Latency = summarizeLatency(latencies)
	providers := make([]string, 0, len(groups))
	for provider := range groups {
		providers = append(providers, provider)
	}
	sort.Strings(providers)
	for _, provider := range providers {

View on GitHub (pinned to 766dce6b13)