Summary
On Windows, the Nowledge Mem Codex Stop hook can be installed/enabled but still fail with:
Saving Codex thread to Nowledge Mem...
error: hook exited with code 1
The failure is not that the hook is disabled. It is caused by Windows shell execution details in the generated hook command and, in some cases, by invoking nmem.cmd from inside the hook.
Environment
Symptoms
hooks.json contains a Stop hook and the status message is shown, but Codex reports the hook failed with exit code 1.
The configured command previously looked like this pattern:
"C:\...\python.exe" "C:\...\nowledge-mem-stop-save.py" --event stop
That pattern works when interpreted by cmd.exe, but in PowerShell a quoted executable path needs the call operator (&). Without that, PowerShell can fail before the Python hook script runs.
Local Root Cause
Two Windows-specific issues were found locally:
- PowerShell parser failure when the hook command string begins with a quoted
python.exe path followed by a quoted script path.
- The Python hook invoked
nmem.cmd, which can leave child processes hanging on this Windows install. Calling the bundled Python CLI module directly was more reliable.
Local Workaround Tested
I added a .cmd wrapper with a simple no-space command target and pointed both user and plugin hook configs at it:
%USERPROFILE%\.codex\hooks\nowledge-mem-stop-save.cmd --event stop
Then patched the Python hook to call the bundled CLI directly instead of shelling through nmem.cmd:
%LOCALAPPDATA%\Nowledge Mem\_up_\python-standalone\python\python.exe -m nowledge_graph_server.ncli --json t save ...
with PYTHONPATH set to the bundled app\src.
Updated local hook config paths:
%USERPROFILE%\.codex\hooks.json
%USERPROFILE%\.codex\plugins\cache\nowledge-community\nowledge-mem\0.1.10\hooks\hooks.json
%USERPROFILE%\.claude\plugins\marketplaces\nowledge-community\nowledge-mem-codex-plugin\hooks\hooks.json
After this workaround:
GET /health -> ok
nmem --json status -> ok
manual wrapper pipeline test -> EXIT=0
hook log -> nmem_exit=0 and Codex thread append success
Suggested Fix
For Windows hook installation, generate a shell-neutral wrapper command instead of a raw quoted Python executable command. Also consider avoiding nmem.cmd inside lifecycle hooks and invoking the bundled Python module directly, so hooks are not affected by cmd/PowerShell quoting or child-process hangs.
Summary
On Windows, the Nowledge Mem Codex Stop hook can be installed/enabled but still fail with:
The failure is not that the hook is disabled. It is caused by Windows shell execution details in the generated hook command and, in some cases, by invoking
nmem.cmdfrom inside the hook.Environment
%LOCALAPPDATA%\Nowledge Mem\...Symptoms
hooks.jsoncontains a Stop hook and the status message is shown, but Codex reports the hook failed with exit code 1.The configured command previously looked like this pattern:
That pattern works when interpreted by
cmd.exe, but in PowerShell a quoted executable path needs the call operator (&). Without that, PowerShell can fail before the Python hook script runs.Local Root Cause
Two Windows-specific issues were found locally:
python.exepath followed by a quoted script path.nmem.cmd, which can leave child processes hanging on this Windows install. Calling the bundled Python CLI module directly was more reliable.Local Workaround Tested
I added a
.cmdwrapper with a simple no-space command target and pointed both user and plugin hook configs at it:Then patched the Python hook to call the bundled CLI directly instead of shelling through
nmem.cmd:with
PYTHONPATHset to the bundledapp\src.Updated local hook config paths:
After this workaround:
Suggested Fix
For Windows hook installation, generate a shell-neutral wrapper command instead of a raw quoted Python executable command. Also consider avoiding
nmem.cmdinside lifecycle hooks and invoking the bundled Python module directly, so hooks are not affected bycmd/PowerShell quoting or child-process hangs.