Bug Description
In ACP mode, the session/workspace cwd appears to be used for tool execution, but not for system-prompt project context discovery.
This creates an inconsistency:
- ACP tools run against the editor session's workspace cwd
- but auto-loaded project context files such as
.hermes.md, AGENTS.md, CLAUDE.md, and .cursorrules do not appear to be resolved from that same ACP session cwd
As a result, Hermes in ACP mode may execute tools in the correct editor workspace while following project instructions loaded from a different directory, or from the process cwd / global TERMINAL_CWD.
Steps to Reproduce
- Start Hermes in ACP mode from a directory that is different from the editor workspace.
- Open a project in Zed / VS Code / JetBrains with a workspace-local
AGENTS.md or .hermes.md.
- Start a new ACP session for that workspace.
- Ask Hermes to inspect files or run tools in the workspace.
- Observe that tool behavior follows the ACP session cwd, but project-context auto-loading does not appear to be explicitly tied to the ACP session cwd.
Expected Behavior
ACP sessions should use the same workspace cwd for both:
- tool execution
- project context file discovery during system prompt construction
If the ACP session cwd is the editor workspace, Hermes should auto-discover project context files from that same directory tree.
Actual Behavior
ACP session cwd is registered as a task-level tool override, so tools are session-aware.
However, system prompt construction in run_agent.py uses:
os.getenv("TERMINAL_CWD"), or
- falls back to
os.getcwd()
I could not find ACP code that explicitly passes the session cwd into build_context_files_prompt(...) or synchronizes ACP session cwd into TERMINAL_CWD before system prompt construction.
This suggests ACP can run tools in one workspace while loading project context from another directory.
Affected Component
- Agent Core (conversation loop, context compression, memory)
- Tools (terminal, file ops, web, code execution, etc.)
- Other
Messaging Platform (if gateway-related)
Debug Report
Not attached. This report is based on source analysis rather than a runtime crash.
Operating System
Windows 11
Python Version
Unknown
Hermes Version
Local repo checkout on main, currently behind origin/main by 7 commits at time of inspection.
Additional Logs / Traceback (optional)
None.
Root Cause Analysis (optional)
Relevant code paths:
- ACP session cwd is registered for tools:
acp_adapter/session.py
_register_task_cwd(task_id, cwd) calls tools.terminal_tool.register_task_env_overrides(task_id, {"cwd": cwd})
tools/terminal_tool.py
terminal_tool(...) resolves cwd via overrides.get("cwd") or config["cwd"]
- Project context discovery during system prompt build:
run_agent.py
_build_system_prompt()
- uses
os.getenv("TERMINAL_CWD") or None
- then calls
build_context_files_prompt(cwd=_context_cwd, skip_soul=_soul_loaded)
- Context file loader fallback:
agent/prompt_builder.py
build_context_files_prompt(cwd=None, ...)
- if
cwd is None, it falls back to os.getcwd()
I could not find code in ACP session creation / prompt handling that:
- passes
state.cwd directly into project context loading, or
- temporarily binds ACP session cwd into
TERMINAL_CWD before prompt construction
So ACP has two cwd paths:
- session-aware cwd for tools
- global/process cwd for prompt context discovery
Bug Description
In ACP mode, the session/workspace
cwdappears to be used for tool execution, but not for system-prompt project context discovery.This creates an inconsistency:
.hermes.md,AGENTS.md,CLAUDE.md, and.cursorrulesdo not appear to be resolved from that same ACP session cwdAs a result, Hermes in ACP mode may execute tools in the correct editor workspace while following project instructions loaded from a different directory, or from the process cwd / global
TERMINAL_CWD.Steps to Reproduce
AGENTS.mdor.hermes.md.Expected Behavior
ACP sessions should use the same workspace cwd for both:
If the ACP session cwd is the editor workspace, Hermes should auto-discover project context files from that same directory tree.
Actual Behavior
ACP session cwd is registered as a task-level tool override, so tools are session-aware.
However, system prompt construction in
run_agent.pyuses:os.getenv("TERMINAL_CWD"), oros.getcwd()I could not find ACP code that explicitly passes the session cwd into
build_context_files_prompt(...)or synchronizes ACP session cwd intoTERMINAL_CWDbefore system prompt construction.This suggests ACP can run tools in one workspace while loading project context from another directory.
Affected Component
Messaging Platform (if gateway-related)
Debug Report
Not attached. This report is based on source analysis rather than a runtime crash.
Operating System
Windows 11
Python Version
Unknown
Hermes Version
Local repo checkout on
main, currently behindorigin/mainby 7 commits at time of inspection.Additional Logs / Traceback (optional)
None.
Root Cause Analysis (optional)
Relevant code paths:
acp_adapter/session.py_register_task_cwd(task_id, cwd)callstools.terminal_tool.register_task_env_overrides(task_id, {"cwd": cwd})tools/terminal_tool.pyterminal_tool(...)resolves cwd viaoverrides.get("cwd") or config["cwd"]run_agent.py_build_system_prompt()os.getenv("TERMINAL_CWD") or Nonebuild_context_files_prompt(cwd=_context_cwd, skip_soul=_soul_loaded)agent/prompt_builder.pybuild_context_files_prompt(cwd=None, ...)cwd is None, it falls back toos.getcwd()I could not find code in ACP session creation / prompt handling that:
state.cwddirectly into project context loading, orTERMINAL_CWDbefore prompt constructionSo ACP has two cwd paths: