Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: adding support for environment variables type dict (#6672)

Fredy Sierra13839b427398
diff --git a/openhands/core/config/utils.py b/openhands/core/config/utils.py
index 4fb7a5278b..b6bf4b77ab 100644
--- a/openhands/core/config/utils.py
+++ b/openhands/core/config/utils.py
@@ -3,6 +3,7 @@ import os
import pathlib
import platform
import sys
+from ast import literal_eval
from types import UnionType
from typing import Any, MutableMapping, get_args, get_origin
from uuid import uuid4
@@ -72,6 +73,9 @@ def load_from_env(cfg: AppConfig, env_or_toml_dict: dict | MutableMapping[str, s
# Attempt to cast the env var to type hinted in the dataclass
if field_type is bool:
cast_value = str(value).lower() in ['true', '1']
+ # parse dicts like SANDBOX_RUNTIME_STARTUP_ENV_VARS
+ elif get_origin(field_type) is dict:
+ cast_value = literal_eval(value)
else:
cast_value = field_type(value)
setattr(sub_config, field_name, cast_value)