Bug Report
Summary: When the current working directory contains a Python package named utils/ (i.e., a directory with utils/__init__.py), the Hermes TUI fails to launch because Python resolves bare imports like from utils import base_url_host_matches to the local utils/ package instead of the installed hermes_agent/utils.py module.
Steps to Reproduce
- Create a directory with a
utils/ subdirectory that is a Python package:
mkdir -p test_cwd/utils
echo "" > test_cwd/utils/__init__.py
cd test_cwd
- Run
hermes --tui
Expected Behavior
The TUI should launch normally, importing base_url_host_matches from the installed hermes_agent.utils module.
Actual Behavior
The TUI fails to launch with an import error because Python finds the local utils/ directory (which does not define base_url_host_matches) instead of the installed hermes_agent.utils module.
Root Cause
The hermes-agent codebase uses bare imports (e.g., from utils import base_url_host_matches) instead of absolute imports (e.g., from hermes_agent.utils import base_url_host_matches). When Python executes in a directory containing a utils/ package, the local directory is on sys.path and shadows the installed package.
Affected Files (non-exhaustive)
The following files in the hermes-agent codebase use from utils import ... and are affected:
| File |
Line |
run_agent.py |
120 |
cli.py |
81 |
agent/model_metadata.py |
19 |
agent/auxiliary_client.py |
52 |
agent/usage_pricing.py |
9 |
agent/anthropic_adapter.py |
23 |
agent/display.py |
16 |
agent/prompt_builder.py |
27 |
agent/models_dev.py |
28 |
trajectory_compressor.py |
44 |
hermes_cli/runtime_provider.py |
32 |
hermes_cli/providers.py |
26 |
hermes_cli/doctor.py |
34 |
hermes_cli/tools_config.py |
28 |
hermes_cli/setup.py |
25 |
hermes_cli/plugins.py |
47 |
gateway/run.py |
92 |
gateway/config.py |
20 |
gateway/platforms/base.py |
22 |
gateway/platforms/weixin.py |
67 |
gateway/channel_directory.py |
15 |
tools/delegate_tool.py |
37 |
tools/transcription_tools.py |
39 |
tools/process_registry.py |
1180 |
batch_runner.py |
711 |
hermes_cli/config.py |
3306, 3964 |
hermes_cli/models.py |
2464 |
hermes_cli/doctor.py |
444 |
Proposed Fix
Replace all bare from utils import ... imports with absolute imports:
# Before:
from utils import base_url_host_matches
# After:
from hermes_agent.utils import base_url_host_matches
This is a straightforward find-and-replace across the codebase. The hermes_agent package namespace is already installed and available at runtime.
Environment
- OS: Linux (containerized)
- hermes-agent version: 0.11.0
- Python: 3.12+
- Working directory structure: Contains
utils/__init__.py (Python package)
Bug Report
Summary: When the current working directory contains a Python package named
utils/(i.e., a directory withutils/__init__.py), the Hermes TUI fails to launch because Python resolves bare imports likefrom utils import base_url_host_matchesto the localutils/package instead of the installedhermes_agent/utils.pymodule.Steps to Reproduce
utils/subdirectory that is a Python package:cd test_cwdhermes --tuiExpected Behavior
The TUI should launch normally, importing
base_url_host_matchesfrom the installedhermes_agent.utilsmodule.Actual Behavior
The TUI fails to launch with an import error because Python finds the local
utils/directory (which does not definebase_url_host_matches) instead of the installedhermes_agent.utilsmodule.Root Cause
The hermes-agent codebase uses bare imports (e.g.,
from utils import base_url_host_matches) instead of absolute imports (e.g.,from hermes_agent.utils import base_url_host_matches). When Python executes in a directory containing autils/package, the local directory is onsys.pathand shadows the installed package.Affected Files (non-exhaustive)
The following files in the hermes-agent codebase use
from utils import ...and are affected:run_agent.pycli.pyagent/model_metadata.pyagent/auxiliary_client.pyagent/usage_pricing.pyagent/anthropic_adapter.pyagent/display.pyagent/prompt_builder.pyagent/models_dev.pytrajectory_compressor.pyhermes_cli/runtime_provider.pyhermes_cli/providers.pyhermes_cli/doctor.pyhermes_cli/tools_config.pyhermes_cli/setup.pyhermes_cli/plugins.pygateway/run.pygateway/config.pygateway/platforms/base.pygateway/platforms/weixin.pygateway/channel_directory.pytools/delegate_tool.pytools/transcription_tools.pytools/process_registry.pybatch_runner.pyhermes_cli/config.pyhermes_cli/models.pyhermes_cli/doctor.pyProposed Fix
Replace all bare
from utils import ...imports with absolute imports:This is a straightforward find-and-replace across the codebase. The
hermes_agentpackage namespace is already installed and available at runtime.Environment
utils/__init__.py(Python package)