Summary
Both ADK and LangGraph dynamic agent loaders use importlib.util.spec_from_file_location to import the user's agent file directly. That call bypasses Python's normal import machinery and never adds the project root to sys.path. Any agent file that uses absolute imports relative to its project root (e.g. from app.config import config) fails to boot with ModuleNotFoundError.
Affected code
libs/idun_agent_engine/src/idun_agent_engine/agent/adk/adk.py lines 435-462 (_load_agent)
libs/idun_agent_engine/src/idun_agent_engine/agent/langgraph/langgraph.py lines 458-514 (_load_graph_builder)
Reproduction
Project layout:
/path/to/myproject/
├── app/
│ ├── __init__.py
│ ├── agent.py # contains: from app.config import config
│ └── config.py
└── config.yaml # agent: app/agent.py:root_agent
From inside /path/to/myproject/:
Engine reload fails with:
ValueError: Failed to load agent from app/agent.py:root_agent: No module named 'app'
Why running from the project cwd does not help
idun init is an installed console script. Python adds the entry-point script's own directory (the venv bin/) to sys.path[0], not the shell's cwd. So launching the server from the project root still doesn't put it on sys.path.
Workaround
PYTHONPATH=. uv run idun init
Suggested fix directions
Several viable strategies, each with trade-offs around namespace packages, programmatic-config callers (ConfigBuilder.from_dict), and hot-reload behavior. Worth a brief design discussion before landing:
- Walk up to a project-root marker (
pyproject.toml, setup.py, setup.cfg) and sys.path.insert it before exec_module.
- Use the directory of the resolved
config.yaml as the project root and add it to sys.path once at boot.
- Add an explicit
project_root field to the agent config.
- Convert the file path to a dotted module name relative to the project root and call
importlib.import_module instead of spec_from_file_location.
Affected versions
Observed on idun-agent-engine==0.6.2. Reproducible against the current docs/standalone-api-and-demo branch.
Summary
Both ADK and LangGraph dynamic agent loaders use
importlib.util.spec_from_file_locationto import the user's agent file directly. That call bypasses Python's normal import machinery and never adds the project root tosys.path. Any agent file that uses absolute imports relative to its project root (e.g.from app.config import config) fails to boot withModuleNotFoundError.Affected code
libs/idun_agent_engine/src/idun_agent_engine/agent/adk/adk.pylines 435-462 (_load_agent)libs/idun_agent_engine/src/idun_agent_engine/agent/langgraph/langgraph.pylines 458-514 (_load_graph_builder)Reproduction
Project layout:
From inside
/path/to/myproject/:Engine reload fails with:
Why running from the project cwd does not help
idun initis an installed console script. Python adds the entry-point script's own directory (the venvbin/) tosys.path[0], not the shell's cwd. So launching the server from the project root still doesn't put it onsys.path.Workaround
Suggested fix directions
Several viable strategies, each with trade-offs around namespace packages, programmatic-config callers (
ConfigBuilder.from_dict), and hot-reload behavior. Worth a brief design discussion before landing:pyproject.toml,setup.py,setup.cfg) andsys.path.insertit beforeexec_module.config.yamlas the project root and add it tosys.pathonce at boot.project_rootfield to the agent config.importlib.import_moduleinstead ofspec_from_file_location.Affected versions
Observed on
idun-agent-engine==0.6.2. Reproducible against the currentdocs/standalone-api-and-demobranch.