Skip to content

fix: resolve home directory correctly on Windows (SOUL.md never loads, exec loops on POSIX commands)#345

Open
Matthew-Selvam wants to merge 1 commit into
Conway-Research:mainfrom
Matthew-Selvam:fix/165-windows-exec-compat
Open

fix: resolve home directory correctly on Windows (SOUL.md never loads, exec loops on POSIX commands)#345
Matthew-Selvam wants to merge 1 commit into
Conway-Research:mainfrom
Matthew-Selvam:fix/165-windows-exec-compat

Conversation

@Matthew-Selvam

Copy link
Copy Markdown

Problem

On Windows, the automaton never loads SOUL.md, constitution.md, or WORKLOG.md, and gets stuck repeatedly issuing ls -la/POSIX commands that fail.

Root cause: process.env.HOME || "/root" is hardcoded at 5 lookup sites. Windows doesn't set HOME (it uses USERPROFILE), so every one of these silently fell back to /root — a path that doesn't exist on Windows. Separately, the model has no signal that it's running on Windows, so it keeps issuing commands cmd.exe doesn't understand.

Fix

  • src/conway/client.ts: execLocal's cwd and resolveLocalPath's tilde-expansion fall back to os.homedir() instead of a hardcoded /root.
  • src/agent/system-prompt.ts, src/soul/model.ts, src/soul/tools.ts: same os.homedir() fallback for constitution/SOUL.md/WORKLOG.md loading.
  • src/agent/tools.ts: the exec tool description is now platform-aware — on process.platform === "win32" it tells the model to use dir/type/findstr/wsl <cmd> instead of POSIX commands, and that cmd.exe doesn't expand ~.

Tests

Added a regression test in soul.test.ts that simulates HOME unset with a Windows-like home directory (via vi.spyOn(os, "homedir")), confirming loadCurrentSoul finds SOUL.md there instead of at a hardcoded path. tsc --noEmit passes; soul.test.ts (42/42), tools-security.test.ts (71/71), and orchestration/local-worker-harness.test.ts (5/5) all pass.

Fixes #165

…, exec loops on POSIX commands)

process.env.HOME || "/root" was hardcoded across 5 lookup sites. On Windows
HOME isn't set (Windows uses USERPROFILE), so every one of these silently
fell back to /root, a path that doesn't exist on Windows. That meant
SOUL.md, constitution.md, and WORKLOG.md were never found, and the local
exec cwd resolved to the wrong place.

Separately, the model had no way to know it was running on Windows, so it
kept issuing POSIX commands (ls, ~) that cmd.exe doesn't understand,
producing a repeating failure loop.

- client.ts: execLocal's cwd and resolveLocalPath's tilde-expansion now
  fall back to os.homedir() instead of a hardcoded /root.
- system-prompt.ts, soul/model.ts, soul/tools.ts: same os.homedir()
  fallback for constitution/SOUL.md/WORKLOG.md loading.
- tools.ts: the exec tool description is now platform-aware — on
  process.platform === "win32" it tells the model to use
  dir/type/findstr/wsl <cmd> instead of POSIX commands, and that cmd.exe
  doesn't expand ~.
- soul.test.ts: regression test simulating HOME unset with a Windows-like
  home dir, confirming loadCurrentSoul resolves it via os.homedir().

Fixes Conway-Research#165
@Matthew-Selvam

Copy link
Copy Markdown
Author

This is ready for maintainer review whenever you get a chance — happy to make any changes requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: Agent loops on 'ls -la' exec failures, never reads SOUL.md in .automaton folder

1 participant