Skip to content

TUI fails to launch when cwd contains a Python package named 'utils/' #15989

@theepicflyer

Description

@theepicflyer

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

  1. Create a directory with a utils/ subdirectory that is a Python package:
    mkdir -p test_cwd/utils
    echo "" > test_cwd/utils/__init__.py
  2. cd test_cwd
  3. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/agentCore agent loop, run_agent.py, prompt buildercomp/cliCLI entry point, hermes_cli/, setup wizardcomp/tuiTerminal UI (ui-tui/ + tui_gateway/)type/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions