Skip to content

[Bug]: Windows: terminal always returns exit_code 126 (root cause + fix) #18454

@wshshz

Description

@wshshz

Bug Description

windows-terminal-126-fix.md

Steps to Reproduce

markdown
Steps to Reproduce

1. 在一台 没有安装 Git for Windows 的 Windows 11 机器上安装 Hermes Agent
2. hermes setup terminal → 选择 local 后端
3. 启动 Hermes,发送任意 terminal 命令:

   Write-Output "hello"

4. 观察结果:exit_code: 126, output: ""
5. 验证:hermes doctor 显示 terminal 工具 ✓ 可用,但实际执行失败
6. 确认根因:where.exe bash 指向 C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\bash.exe(WSL 存根)

Expected Behavior

terminal 工具正常执行命令,返回 exit_code: 0 和命令输出。

Actual Behavior

所有命令返回 exit_code: 126,output 为空。静默失败,无错误日志。

Expected Behavior

markdown
Expected Behavior

terminal 工具正常执行命令,返回 exit_code: 0 和命令输出。

Actual Behavior

所有命令返回 exit_code: 126,output 为空。静默失败,无错误日志。


Expected: 能跑 → 返回 0
Actual: 全炸 → 全部 126

简洁直接,GitHub Issue 标准格式 (`・ω・)b

Actual Behavior

markdown
Actual Behavior

所有命令返回 exit_code: 126,output 为空。静默失败,无错误日志。

| 命令 | exit_code | output |
|------|-----------|--------|
| Write-Output "hello" | 126 | (空) |
| echo test | 126 | (空) |
| ls | 126 | (空) |
| pwd | 126 | (空) |

Affected Component

Tools (terminal, file ops, web, code execution, etc.)

Messaging Platform (if gateway-related)

N/A (CLI only)

Debug Report

markdown
    Debug Report

    Generated via hermes debug share:

    - Report: https://paste.rs/TLn5a
    - agent.log: https://paste.rs/MSi1B
    - gateway.log: https://paste.rs/ErG6H

    ⚠️ Pastes auto-delete in 6 hours.


    现在你的 Issue 应该包含这些部分:


    ✅ 标题 + 省流版
    ✅ 问题现象
    ✅ Steps to Reproduce
    ✅ Expected Behavior
    ✅ Actual Behavior
    ✅ Which part: tools
    ✅ 排查过程
    ✅ 根因分析
    ✅ 修复方案
    ✅ 修复后验证
    ✅ 建议改进
    ✅ 环境信息
    ✅ Debug Report


    可以发 Issue 了!https://github.com/NousResearch/hermes-agent/issues/new (`・ω・´)ノ

Operating System

windows 11

Python Version

3.11.9

Hermes Version

v0.12.0

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existsbackend/localLocal shell executioncomp/toolsTool registry, model_tools, toolsetsduplicateThis issue or pull request already existstool/terminalTerminal execution and process managementtype/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