Skip to content

fix(evaluation): open eval/session JSON files as UTF-8 - #6690

Open
moneebarif1 wants to merge 2 commits into
google:mainfrom
moneebarif1:fix/eval-open-utf8-encoding
Open

fix(evaluation): open eval/session JSON files as UTF-8#6690
moneebarif1 wants to merge 2 commits into
google:mainfrom
moneebarif1:fix/eval-open-utf8-encoding

Conversation

@moneebarif1

Copy link
Copy Markdown

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. 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.

Changes

Pass encoding="utf-8" to make behavior deterministic across platforms:

  • evaluation/agent_evaluator.py
    • load_json() — reads eval/test JSON
    • _generate_responses... — writes regenerated eval data
    • _get_initial_session() — reads the initial session JSON
  • evaluation/evaluation_generator.py
    • reads the session file before generating responses

This 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 in agent_evaluator.py itself) — 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.

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.
@adk-bot adk-bot added the eval [Component] This issue is related to evaluation label Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eval [Component] This issue is related to evaluation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants