[BUG] ExperimentResults to_json uses locale encoding on Windows
Author: MohammadHijjawi97Created Sep 17, 2026Updated Sep 17, 2026
Description
ExperimentResults.to_json and compare_with_baseline open result files with the locale encoding. On Windows that is often cp1252, so UTF-8 identifiers and metadata raise UnicodeEncodeError. json.dump also has no default encoder, so datetime values in metadata raise TypeError.
Steps to Reproduce
from pathlib import Path
from crewai.experimental.evaluation.experiment.result import ExperimentResult, ExperimentResults
results = ExperimentResults(
[ExperimentResult(identifier="café", inputs={}, score=1, expected_score=1, passed=True)],
metadata={"note": "résumé"},
)
results.to_json(str(Path("out.json")))Run with a cp1252 locale.
Expected behavior
Files are written and read as UTF-8. Non-JSON metadata values are stringified instead of crashing.
Screenshots/Code snippets
UnicodeEncodeError: 'charmap' codec can't encode character
Operating System
Windows 11
Python Version
3.12
crewAI Version
main
Source: crewAIInc/crewAI