Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions oocana/oocana/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class Context:
__package_name: str | None = None
_logger: Optional[logging.Logger] = None
__pkg_data_dir: str
__oomol_llm_env_warned: bool = False

# TODO: remove the pkg_dir parameter, use pkg_data_dir instead.
def __init__(
Expand Down Expand Up @@ -310,11 +311,14 @@ def oomol_llm_env(self) -> OOMOL_LLM_ENV:
"models": os.getenv("OOMOL_LLM_MODELS", "").split(","),
}

for key, value in oomol_llm_env.items():
if value == "" or value == []:
self.send_warning(
f"OOMOL_LLM_ENV variable {key} is ({value}), this may cause some features not working properly."
)
# Only warn once on first access to avoid repeated side effects
if not self.__oomol_llm_env_warned:
self.__oomol_llm_env_warned = True
for key, value in oomol_llm_env.items():
if value == "" or value == []:
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comparison value == [] on line 318 will never match the "models" value when the environment variable is empty or not set. When OOMOL_LLM_MODELS is empty, "".split(",") returns [''] (a list with one empty string), not [] (an empty list). This means warnings for empty models won't be sent as intended. Consider using value == [""] or checking value == [] or value == [""] to handle this case correctly.

Suggested change
if value == "" or value == []:
if (
(isinstance(value, str) and value == "")
or (isinstance(value, list) and (value == [] or value == [""]))
):

Copilot uses AI. Check for mistakes.
self.send_warning(
f"OOMOL_LLM_ENV variable {key} is ({value}), this may cause some features not working properly."
)

return oomol_llm_env

Expand Down
Loading