hermes - 💡(How to fix) Fix [Bug]: Container on WSL host gets wrong environment hint — /mnt/c/ paths suggested but unavailable

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Not applicable — hermes debug share captures crashes, tracebacks, and environment details. This bug is a logic error in environment detection (is_wsl() returns True inside containers on WSL, but build_environment_hints() never checks is_container()). No crash occurs; the symptom is incorrect system prompt content (wrong environment hint constant injected).

To verify the root cause without a debug share, run inside a container on WSL2: python -c "from hermes_constants import is_wsl, is_container; print(f'is_wsl={is_wsl()}, is_container={is_container()}')" Expected output: is_wsl=True, is_container=True The prompt builder only checks is_wsl(), missing the container context.

Root Cause

The root cause: is_wsl() checks /proc/version for the microsoft marker, which is still present inside containers running on a WSL kernel. The existing is_container() function (in hermes_constants.py) correctly detects the container environment, but build_environment_hints() in agent/prompt_builder.py never checks it — it only calls is_wsl().

Fix Action

Fix / Workaround

This causes the agent to attempt file operations at /mnt/c/Users/... which silently fail, or to recommend WSL-specific workarounds (like wslpath) that don't work inside the container.

Code Example

# From WSL2 on Windows
   docker run -it --rm hermes-agent
   # or
   podman run -it --rm hermes-agent

---

What operating system am I running on? Are Windows paths available?

---

List the contents of /mnt/c/Users/

---

Not applicable — `hermes debug share` captures crashes, tracebacks, and environment details. This bug is a logic error in environment detection (`is_wsl()` returns True inside containers on WSL, but `build_environment_hints()` never checks `is_container()`). No crash occurs; the symptom is incorrect system prompt content (wrong environment hint constant injected).

To verify the root cause without a debug share, run inside a container on WSL2:
  python -c "from hermes_constants import is_wsl, is_container; print(f'is_wsl={is_wsl()}, is_container={is_container()}')"
Expected output: is_wsl=True, is_container=True
The prompt builder only checks is_wsl(), missing the container context.

---

No traceback — silent logic error. The symptom is the wrong hint constant appearing in the system prompt.

Current code in agent/prompt_builder.py (build_environment_hints, tail of function):
    if is_wsl():
        hints.append(WSL_ENVIRONMENT_HINT)    # ← fires inside containers on WSL

Expected logic:
    if is_container() and is_wsl():
        hints.append(CONTAINER_IN_WSL_ENVIRONMENT_HINT)
    elif is_wsl():
        hints.append(WSL_ENVIRONMENT_HINT)
RAW_BUFFERClick to expand / collapse

Bug Description

When running hermes-agent inside a Docker/Podman container on a WSL2 host, the agent incorrectly injects WSL_ENVIRONMENT_HINT into the system prompt. This hint tells the agent that /mnt/c/ Windows paths are available — but those paths do not exist inside the container unless explicitly bind-mounted.

The root cause: is_wsl() checks /proc/version for the microsoft marker, which is still present inside containers running on a WSL kernel. The existing is_container() function (in hermes_constants.py) correctly detects the container environment, but build_environment_hints() in agent/prompt_builder.py never checks it — it only calls is_wsl().

This causes the agent to attempt file operations at /mnt/c/Users/... which silently fail, or to recommend WSL-specific workarounds (like wslpath) that don't work inside the container.

Steps to Reproduce

  1. Run hermes-agent inside a Docker/Podman container on a WSL2 host:
    # From WSL2 on Windows
    docker run -it --rm hermes-agent
    # or
    podman run -it --rm hermes-agent
  2. Start a chat session and ask the agent about the environment:
    What operating system am I running on? Are Windows paths available?
  3. Observe: The agent reports it is running on WSL and that /mnt/c/ paths are available.
  4. Ask the agent to list or read a file at /mnt/c/Users/:
    List the contents of /mnt/c/Users/
  5. Observe: The operation fails — /mnt/c/ does not exist inside the container (unless explicitly bind-mounted with -v /mnt/c:/mnt/c).

Expected Behavior

When running inside a container on WSL, the agent should receive a hint that:

  • It is in a container environment on a WSL host
  • /mnt/c/ Windows paths are not automatically available
  • WSL-specific tools like wslpath are not available

Actual Behavior

The agent receives WSL_ENVIRONMENT_HINT, which states that:

  • /mnt/c/ paths are available (they are not)
  • wslpath can be used to convert paths (it cannot)
  • The user's Windows files are at /mnt/c/Users/<username>/ (not accessible from the container)

Affected Component

Agent Core (conversation loop, context compression, memory), CLI (interactive chat)

Messaging Platform (if gateway-related)

N/A (CLI only)

Debug Report

Not applicable — `hermes debug share` captures crashes, tracebacks, and environment details. This bug is a logic error in environment detection (`is_wsl()` returns True inside containers on WSL, but `build_environment_hints()` never checks `is_container()`). No crash occurs; the symptom is incorrect system prompt content (wrong environment hint constant injected).

To verify the root cause without a debug share, run inside a container on WSL2:
  python -c "from hermes_constants import is_wsl, is_container; print(f'is_wsl={is_wsl()}, is_container={is_container()}')"
Expected output: is_wsl=True, is_container=True
The prompt builder only checks is_wsl(), missing the container context.

Operating System

Windows 11 WSL2 (Ubuntu 22.04/24.04) running hermes-agent inside Docker/Podman container

Python Version

3.11

Hermes Version

v0.13.0 (reproduced on current main as of May 2026)

Additional Logs / Traceback (optional)

No traceback — silent logic error. The symptom is the wrong hint constant appearing in the system prompt.

Current code in agent/prompt_builder.py (build_environment_hints, tail of function):
    if is_wsl():
        hints.append(WSL_ENVIRONMENT_HINT)    # ← fires inside containers on WSL

Expected logic:
    if is_container() and is_wsl():
        hints.append(CONTAINER_IN_WSL_ENVIRONMENT_HINT)
    elif is_wsl():
        hints.append(WSL_ENVIRONMENT_HINT)

Root Cause Analysis (optional)

In agent/prompt_builder.py, build_environment_hints() checks only is_wsl() when deciding whether to append the WSL environment hint:

    # ... local/remote backend handling (~60 lines) ...

    if is_wsl():
        hints.append(WSL_ENVIRONMENT_HINT)

### Proposed Fix (optional)

I have a working fix already submitted as PR #15265 (`fix/container-wsl-environment-hint` branch). The changes are:

- `agent/prompt_builder.py` — import `is_container`, add `CONTAINER_IN_WSL_ENVIRONMENT_HINT` constant, update the WSL check at the end of `build_environment_hints()` to check container+WSL first
- `tests/agent/test_prompt_builder.py` — add 2 new tests for container-in-WSL scenarios, update existing tests to also mock `is_container`

### Are you willing to submit a PR for this?

- [x] I'd like to fix this myself and submit a PR

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix [Bug]: Container on WSL host gets wrong environment hint — /mnt/c/ paths suggested but unavailable