fix(evaluation): open eval/session JSON files as UTF-8 - #6690
Open
moneebarif1 wants to merge 2 commits into
Open
fix(evaluation): open eval/session JSON files as UTF-8#6690moneebarif1 wants to merge 2 commits into
moneebarif1 wants to merge 2 commits into
Conversation
Four open() calls in the evaluation module read/write JSON eval data and session files without an explicit encoding, so they fall back to the platform default (e.g. cp1252 on Windows). Eval datasets and sessions routinely contain non-ASCII text (model prompts/responses in other languages, emoji), so on non-UTF-8 locales these calls raise UnicodeDecodeError on read or write mojibake on save. Pass encoding="utf-8" to make the behavior deterministic across platforms, matching the rest of the evaluation module (local_eval_sets_manager, eval_config, local_eval_set_results_manager) which already do this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four
open()calls in the evaluation module read/write JSON eval data and session files without an explicit encoding, so they fall back to the platform default (e.g.cp1252on Windows). Eval datasets and sessions routinely contain non-ASCII text (model prompts/responses in other languages, emoji), so on non-UTF-8 locales these calls raiseUnicodeDecodeErroron read or write mojibake on save.Changes
Pass
encoding="utf-8"to make behavior deterministic across platforms:evaluation/agent_evaluator.pyload_json()— reads eval/test JSON_generate_responses...— writes regenerated eval data_get_initial_session()— reads the initial session JSONevaluation/evaluation_generator.pyThis matches the rest of the evaluation module, which already opens files with
encoding="utf-8"(local_eval_sets_manager.py,eval_config.py,local_eval_set_results_manager.py, and one existing call inagent_evaluator.pyitself) — so these four were inconsistent oversights.Testing
No behavioral change on UTF-8-default platforms; the fix removes locale-dependent failures on Windows/other locales. Existing evaluation tests continue to pass.