fix: Windows Path Handling and Normalize Cross-Platform Path Resolution in AgentLoader

Merge https://github.com/google/adk-python/pull/3609

Co-authored-by: George Weale <gweale@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3609 from p-kris10:fix/windows-cmd 8cb0310bd4450097a0a7714eaac6521b6a447442
PiperOrigin-RevId: 836395714
This commit is contained in:
Kristen Pereira
2025-11-24 16:07:40 -08:00
committed by Copybara-Service
parent cf21ca3584
commit a1c09b724b
4 changed files with 143 additions and 8 deletions
+1 -1
View File
@@ -132,7 +132,7 @@ def resolve_agent_reference(
else:
return from_config(
os.path.join(
referencing_agent_config_abs_path.rsplit("/", 1)[0],
os.path.dirname(referencing_agent_config_abs_path),
ref_config.config_path,
)
)
+8 -7
View File
@@ -58,7 +58,7 @@ class AgentLoader(BaseAgentLoader):
"""
def __init__(self, agents_dir: str):
self.agents_dir = agents_dir.rstrip("/")
self.agents_dir = str(Path(agents_dir))
self._original_sys_path = None
self._agent_cache: dict[str, Union[BaseAgent, App]] = {}
@@ -272,12 +272,13 @@ class AgentLoader(BaseAgentLoader):
f"No root_agent found for '{agent_name}'. Searched in"
f" '{actual_agent_name}.agent.root_agent',"
f" '{actual_agent_name}.root_agent' and"
f" '{actual_agent_name}/root_agent.yaml'.\n\nExpected directory"
f" structure:\n <agents_dir>/\n {actual_agent_name}/\n "
" agent.py (with root_agent) OR\n root_agent.yaml\n\nThen run:"
f" adk web <agents_dir>\n\nEnsure '{agents_dir}/{actual_agent_name}' is"
" structured correctly, an .env file can be loaded if present, and a"
f" root_agent is exposed.{hint}"
f" '{actual_agent_name}{os.sep}root_agent.yaml'.\n\nExpected directory"
f" structure:\n <agents_dir>{os.sep}\n "
f" {actual_agent_name}{os.sep}\n agent.py (with root_agent) OR\n "
" root_agent.yaml\n\nThen run: adk web <agents_dir>\n\nEnsure"
f" '{os.path.join(agents_dir, actual_agent_name)}' is structured"
" correctly, an .env file can be loaded if present, and a root_agent"
f" is exposed.{hint}"
)
def _record_origin_metadata(