From 201db5afcbc8f5984eab3249f063ed8e3c9ef58c Mon Sep 17 00:00:00 2001 From: Alberto Simoes <104087721+cx-alberto-simoes@users.noreply.github.com> Date: Thu, 8 Jan 2026 15:00:00 +0000 Subject: [PATCH] Instead of checking for extension, check if file exists --- src/serena/config/context_mode.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/serena/config/context_mode.py b/src/serena/config/context_mode.py index 205e9141..83298ab4 100644 --- a/src/serena/config/context_mode.py +++ b/src/serena/config/context_mode.py @@ -124,7 +124,9 @@ class SerenaAgentMode(ToolInclusionDefinition, ToStringMixin): @classmethod def load(cls, name_or_path: str | Path) -> Self: - if str(name_or_path).endswith(".yml"): + # Check if it's a file path that exists + path = Path(name_or_path) + if path.exists() and path.is_file(): return cls.from_yaml(name_or_path) return cls.from_name(str(name_or_path)) @@ -225,7 +227,9 @@ class SerenaAgentContext(ToolInclusionDefinition, ToStringMixin): @classmethod def load(cls, name_or_path: str | Path) -> Self: - if str(name_or_path).endswith(".yml"): + # Check if it's a file path that exists + path = Path(name_or_path) + if path.exists() and path.is_file(): return cls.from_yaml(name_or_path) return cls.from_name(str(name_or_path))