JuliusBrussee/caveman · error
cachebench: replay request
Error message
cachebench: replay request %q needs %s billed-token metadata
What it means
ValidateReplay enforces RequireProviderTokens (or grounded-timing) metadata: request %q lacks %s billed-token basis, i.e. its TokenBasis is not provider-counted when limits demand provider-counted metadata. Claims about savings must be grounded in provider-counted usage.
Solutions
- Re-emit the trace with the current writer so records carry billed-token metadata
- Migrate old traces to the current schema before replay
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cacheengine/cachebench/replay.go:379 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/6526a82dfe39b742.
Report an issue: GitHub.
Appendix: source
Thrown at cacheengine/cachebench/replay.go:379
}
if len(records) > limits.MaxRequests {
return ReplayPreflight{}, fmt.Errorf("cachebench: replay population %d exceeds request limit %d", len(records), limits.MaxRequests)
}
if timeScale <= 0 || math.IsNaN(timeScale) || math.IsInf(timeScale, 0) || timeScale > 1000 {
return ReplayPreflight{}, errors.New("cachebench: time scale must be greater than zero and at most 1000")
}
seen := make(map[string]bool, len(records))
timing := map[string]bool{}
tokens := map[string]bool{}
var previous time.Time
var declaredInput, declaredOutput, worstCase, scheduled int64
for index, record := range records {
if seen[record.RequestID] {
return ReplayPreflight{}, fmt.Errorf("cachebench: duplicate replay request %q", record.RequestID)
}
seen[record.RequestID] = true
if record.Schema != TraceSchema {
return ReplayPreflight{}, fmt.Errorf("cachebench: replay request %q needs %s billed-token metadata", record.RequestID, TraceSchema)
}
if _, err := record.NativeRequest(); err != nil {
return ReplayPreflight{}, fmt.Errorf("cachebench: replay request %d: %w", index, err)
}
at, err := time.Parse(time.RFC3339Nano, record.At)
if err != nil || !previous.IsZero() && at.Before(previous) {
return ReplayPreflight{}, fmt.Errorf("cachebench: replay request %q has invalid time order", record.RequestID)
}
if limits.RequireGroundedTiming && record.TimingBasis != TimingGrounded {
return ReplayPreflight{}, fmt.Errorf("cachebench: replay request %q timing basis %q is not globally grounded", record.RequestID, record.TimingBasis)
}
timing[record.TimingBasis] = true
if limits.RequireProviderTokens && record.TokenBasis != TokenProviderCounted {
return ReplayPreflight{}, fmt.Errorf("cachebench: replay request %q token basis %q is not provider-counted", record.RequestID, record.TokenBasis)
}
tokens[record.TokenBasis] = true
if record.DeclaredInputTokens <= 0 || record.DeclaredInputTokens < record.PrefixTokens || record.MaxOutputTokens <= 0 || !requestBudgetMatchesBody(record) {
return ReplayPreflight{}, fmt.Errorf("cachebench: replay request %q has invalid billed-token budget", record.RequestID)View on GitHub (pinned to 766dce6b13)