diff --git a/agent/nous_rate_guard.py b/agent/nous_rate_guard.py index 415d367ca17b..0234eef2ea23 100644 --- a/agent/nous_rate_guard.py +++ b/agent/nous_rate_guard.py @@ -117,7 +117,7 @@ def record_nous_rate_limit( # Atomic write: write to temp file + rename fd, tmp_path = tempfile.mkstemp(dir=state_dir, suffix=".tmp") try: - with os.fdopen(fd, "w") as f: + with os.fdopen(fd, "w", encoding="utf-8") as f: json.dump(state, f) atomic_replace(tmp_path, path) except Exception: diff --git a/agent/shell_hooks.py b/agent/shell_hooks.py index 3f155f20465c..f30125b45983 100644 --- a/agent/shell_hooks.py +++ b/agent/shell_hooks.py @@ -642,7 +642,7 @@ def save_allowlist(data: Dict[str, Any]) -> None: prefix=f"{p.name}.", suffix=".tmp", dir=str(p.parent), ) try: - with os.fdopen(fd, "w") as fh: + with os.fdopen(fd, "w", encoding="utf-8") as fh: fh.write(json.dumps(data, indent=2, sort_keys=True)) atomic_replace(tmp_path, p) except Exception: