JuliusBrussee/caveman · error

retained corpus byte limit

Error message

retained corpus byte limit %d exceeded

What it means

Adding this row would push the total retained corpus bytes (sum of per-row retained sizes tracked incrementally) past limits.MaxTotalBytes. This is the aggregate memory bound, distinct from the per-row limit.

Solutions

  1. Raise the aggregate byte limit for larger benchmarks
  2. Trim message content or drop low-value rows before reading
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cacheengine/cachebench/corpus.go:400 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/2ab9ebf5c5398684. Report an issue: GitHub.

Appendix: source

Thrown at cacheengine/cachebench/corpus.go:400

	if message.Role == "tool" && message.ToolCallID == "" {
		return errors.New("tool message requires tool_call_id")
	}
	return nil
}

func appendCorpusRow(rows *[]CorpusRow, sessions map[string]bool, retainedBytes *int64, row CorpusRow, limits CorpusLimits) error {
	if len(*rows) >= limits.MaxRows {
		return fmt.Errorf("row limit %d exceeded", limits.MaxRows)
	}
	if !sessions[row.SessionID] {
		if len(sessions) >= limits.MaxSessions {
			return fmt.Errorf("session limit %d exceeded", limits.MaxSessions)
		}
		sessions[row.SessionID] = true
	}
	rowBytes := corpusRowRetainedBytes(row)
	if rowBytes > limits.MaxRetainedBytes-*retainedBytes {
		return fmt.Errorf("retained corpus byte limit %d exceeded", limits.MaxRetainedBytes)
	}
	*retainedBytes += rowBytes
	*rows = append(*rows, row)
	return nil
}

func corpusRetainedBytes(rows []CorpusRow) int64 {
	var total int64
	for _, row := range rows {
		total += corpusRowRetainedBytes(row)
	}
	return total
}

func corpusRowRetainedBytes(row CorpusRow) int64 {
	total := int64(len(row.SessionID) + len(row.Model))
	for _, message := range row.Input {
		total += int64(len(message.Role) + len(message.Content) + len(message.ToolCallID) + len(message.Name))

View on GitHub (pinned to 766dce6b13)