Skip to content

PostToolUse fires on Codex and then cannot save: the per-tool-call path resolves a session dir under ~/.claude/projects/ #459

Closed

Description

@fdaviddpt

Observed against codex-cli 0.150.1 on macOS 15.3.2 arm64, with main at f79f1c5 — every Codex fix merged (#443, #444, #451).

Symptom

PostToolUse now fires on Codex, and every firing logs this and saves nothing:

12:30:41 [hook] post-tool: PROJECT_DIR=.../codextest5 PIPELINE_DIR=/Users/<user>/.codex/plugins/cache/dpt-plugins/remember/0.23.0 PYTHON=python3 REMEMBER_DIR=.../codextest5/.remember
12:30:41 [hook] WARNING: no session dir for this project: /Users/<user>/.claude/projects/-private-tmp-...-codextest5 (slug of /private/tmp/.../codextest5). Memory cannot save until it matches a directory under /Users/<user>/.claude/projects/

The session-end path in the same session is unaffected and works: [extract] 3 exchanges (1 human).

Location

The per-tool-call save path reached from scripts/post-tool-hook.sh, wherever it resolves a session directory by slugging PROJECT_DIR under ~/.claude/projects/.

Mechanism

~/.claude/projects/<slug> is Claude Code's own transcript layout. Codex writes its sessions to ~/.codex/sessions/<yyyy>/<mm>/<dd>/rollout-<date>-<uuid>.jsonl instead, so the slug never matches a directory that exists and the per-tool-call save declines every time.

This is the same class #407 already fixed one layer up: the pipeline used to reconstruct the transcript path from the project directory, and #407 taught it to read the host-supplied transcript_path instead. That fix reached find_session(). This call site still derives a location from PROJECT_DIR rather than from what the host handed it.

Note what has to be true for this to have surfaced only now: before #444 the hook could not resolve PROJECT_DIR at all, so it exited early and never reached this check. #444 fixed the resolution and revealed the next thing in line. That is the third time in this sequence that fixing one silent failure exposed the next (#443 → #451 → this).

Why priority:high

Per-tool-call capture is what keeps memory current during a long session rather than only at its end. On Codex it is entirely inert. It is not silent — the WARNING is loud and correct, which is the one good thing here — but a user reading it is told to make a directory under ~/.claude/projects/, which is advice for the wrong host and would not help them.

That misdirection is worth naming separately: the remedy the warning names does not apply on the host where the warning fires.

What would settle it

Route this call site through the same host-supplied path #407 introduced, rather than deriving from PROJECT_DIR — pipeline/host.py already resolves transcript_path and, since #443, sniffs which host wrote it. If a session directory genuinely is needed rather than a transcript file, then the derivation needs a host-aware branch and the warning needs to name the right location per host.

A test needs a Codex-shaped PostToolUse payload with no ~/.claude/projects/<slug> present, asserting a save happens. Pair it with the control this repo keeps needing: an assertion that the save occurred passes just as well when the hook never ran.

Part of #406.

Activity

  1. added
    bug
    priority:high
    on Aug 29, 2026
  2. self-assigned this
    on Aug 29, 2026
  3. fdaviddpt commented on Aug 29, 2026

    @fdaviddpt
    ContributorAuthor

    Correction to the comment above: both closing references in #464's body bound correctly. gh-pr-merge's read-back ran before GitHub had finished processing the second one, so it reported #459: OPEN — did NOT close; by the time I went to close it by hand it was already closed. The op was right to report what it read — the body was not malformed.

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

Metadata

Metadata

Assignees

Labels

bugpriority:high

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions