diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py index 0afb0add20bf6..490f84dc26720 100644 --- a/agent/auxiliary_client.py +++ b/agent/auxiliary_client.py @@ -1307,7 +1307,7 @@ def _read_nous_auth() -> Optional[dict]: try: if not _AUTH_JSON_PATH.is_file(): return None - data = json.loads(_AUTH_JSON_PATH.read_text()) + data = json.loads(_AUTH_JSON_PATH.read_text(encoding="utf-8")) if data.get("active_provider") != "nous": return None provider = data.get("providers", {}).get("nous", {}) diff --git a/agent/copilot_acp_client.py b/agent/copilot_acp_client.py index e3c03938af40d..4b5f67ca0caaa 100644 --- a/agent/copilot_acp_client.py +++ b/agent/copilot_acp_client.py @@ -630,7 +630,7 @@ def _handle_server_message( if block_error: raise PermissionError(block_error) try: - content = path.read_text() + content = path.read_text(encoding="utf-8") except FileNotFoundError: content = "" line = params.get("line") @@ -659,7 +659,7 @@ def _handle_server_message( f"Write denied: '{path}' is a protected system/credential file." ) path.parent.mkdir(parents=True, exist_ok=True) - path.write_text(str(params.get("content") or "")) + path.write_text(str(params.get("content") or ""), encoding="utf-8") response = { "jsonrpc": "2.0", "id": message_id, diff --git a/agent/credential_sources.py b/agent/credential_sources.py index f99a758625746..ec25eda87d79e 100644 --- a/agent/credential_sources.py +++ b/agent/credential_sources.py @@ -164,7 +164,7 @@ def _remove_env_source(provider: str, removed) -> RemovalResult: if env_path.exists(): env_in_dotenv = any( line.strip().startswith(f"{env_var}=") - for line in env_path.read_text(errors="replace").splitlines() + for line in env_path.read_text(encoding="utf-8", errors="replace").splitlines() ) except OSError: pass diff --git a/agent/shell_hooks.py b/agent/shell_hooks.py index 97ba3862120bc..c9aec296818e2 100644 --- a/agent/shell_hooks.py +++ b/agent/shell_hooks.py @@ -603,7 +603,7 @@ def allowlist_path() -> Path: def load_allowlist() -> Dict[str, Any]: """Return the parsed allowlist, or an empty skeleton if absent.""" try: - raw = json.loads(allowlist_path().read_text()) + raw = json.loads(allowlist_path().read_text(encoding="utf-8")) except (FileNotFoundError, json.JSONDecodeError, OSError): return {"approvals": []} if not isinstance(raw, dict): diff --git a/tools/managed_tool_gateway.py b/tools/managed_tool_gateway.py index d894dcb4b29b2..2bbc9dcff16ce 100644 --- a/tools/managed_tool_gateway.py +++ b/tools/managed_tool_gateway.py @@ -37,7 +37,7 @@ def _read_nous_provider_state() -> Optional[dict]: path = auth_json_path() if not path.is_file(): return None - data = json.loads(path.read_text()) + data = json.loads(path.read_text(encoding="utf-8")) providers = data.get("providers", {}) if not isinstance(providers, dict): return None diff --git a/tools/skills_sync.py b/tools/skills_sync.py index a8a7265f95bf1..3127c80c8dd46 100644 --- a/tools/skills_sync.py +++ b/tools/skills_sync.py @@ -373,7 +373,7 @@ def _backfill_optional_provenance(quiet: bool = False) -> List[str]: lock_path = SKILLS_DIR / ".hub" / "lock.json" try: - data = json.loads(lock_path.read_text()) if lock_path.exists() else {"version": 1, "installed": {}} + data = json.loads(lock_path.read_text(encoding="utf-8")) if lock_path.exists() else {"version": 1, "installed": {}} except (json.JSONDecodeError, OSError): data = {"version": 1, "installed": {}} installed = data.setdefault("installed", {})