Skip to content

fix(config): sessions/transcripts honor $CLAWCODEX_CONFIG_DIR#707

Merged
ericleepi314 merged 1 commit into
mainfrom
fix/session-dir-honor-config-override
Jul 13, 2026
Merged

fix(config): sessions/transcripts honor $CLAWCODEX_CONFIG_DIR#707
ericleepi314 merged 1 commit into
mainfrom
fix/session-dir-honor-config-override

Conversation

@ericleepi314

Copy link
Copy Markdown
Collaborator

Why

sessions/ and transcripts/ were hardcoded to Path.home()/".clawcodex" in ~10 sites and ignored $CLAWCODEX_CONFIG_DIR, while config/memory/skills/auth/mcp all honor it. This inconsistency is what forced #706's # Environment prompt hint to anchor on Path.home() (so it wouldn't authoritatively misdirect the model under the override). This is the real fix the Critic recommended in #706's review.

What

  • Add get_sessions_dir() / get_transcripts_dir() to the canonical src/utils/clawcodex_dirs.py resolver (= get_user_config_dir()/"sessions"|"transcripts").
  • Route every session/transcript reader + writer through them:
    • services/session_storage.py::SESSIONS_DIR (resolver-computed; kept as a patchable module attribute — two tests monkeypatch it, internal fallbacks read it)
    • agent/session.py save()/load()
    • services/cost_restore.py::_sessions_dir, server/agent_server.py::_sessions_dir (covers all /resume + list_sessions paths)
    • memdir/memdir.py — the "search past context" prompt line (a model-facing session-path surface)
    • agent/transcript.py::_transcripts_root (propagates to get_agent_transcript_path, get_workflow_run_path, transcripts/workflows/ journals)
  • Flip the # Environment line back to get_user_config_dir() — correct in both configs (reverses fix(prompt): name ~/.clawcodex in # Environment so the model finds session history #706's Path.home() anchor + its test).

Compatibility

  • Default users: no move. get_user_config_dir() == ~/.clawcodex, so resolved paths are byte-identical to the old hardcoded ones.
  • Override users: clean switch, no legacy fallback — matches how config/memory/skills already behave (none fall back; no installer sets the override — it's opt-in, with 24 read sites). Setting the override after accumulating sessions means /resume looks under the new root; noted in CHANGELOG.

Out of scope (still home-anchored)

server-sessions.json (Direct Connect index), uploads/, workflows/, plans/, worktrees (git-registered, can't move). server-sessions.json is a reasonable follow-up (also session state).

Tests

  • New tests/utils/test_clawcodex_dirs.py (default / override / same-root-as-config / ~-expansion).
  • Env-line test flipped to test_follows_config_dir_override; drift guard ties the line to the real SESSIONS_DIR + transcript sources.
  • ~476 tests green across prompt/session/transcript/memdir/server/cost/resume suites; 0 regressions.

Reviewed via the Critic loop → APPROVE (verified completeness, reader/writer partitioning by store, no import cycle, dead-import safety).

🤖 Generated with Claude Code

The sessions/ and transcripts/ stores were hardcoded to
Path.home()/".clawcodex" in ~10 sites and ignored $CLAWCODEX_CONFIG_DIR,
while config/memory/skills/auth/mcp all honor it. This made the override
inconsistent and previously forced the # Environment prompt hint (PR #706)
to anchor on Path.home() so it wouldn't misdirect the model under the
override.

Add get_sessions_dir()/get_transcripts_dir() to the canonical
clawcodex_dirs resolver (= get_user_config_dir()/"sessions"|"transcripts")
and route every session/transcript reader+writer through them:
session_storage.SESSIONS_DIR (resolver-computed; kept as a patchable
module attribute), agent/session.py save+load, cost_restore._sessions_dir,
agent_server._sessions_dir (all /resume + list paths), the memdir
"search past context" prompt line, and agent/transcript._transcripts_root
(propagates to transcripts/workflows/ journals). The # Environment line
flips back to get_user_config_dir(), correct in both configs.

Default users are unaffected: get_user_config_dir() == ~/.clawcodex, so the
resolved paths are byte-identical to the old hardcoded ones (no move). With
the override set, the stores relocate under it — a clean switch with no
legacy fallback, matching how config/memory/skills already behave.

Out of scope (still home-anchored): server-sessions.json (Direct Connect
index), uploads/, workflows/, plans/, worktrees (git-registered).

Tests: new tests/utils/test_clawcodex_dirs.py (default/override/expansion);
env-line test flipped to assert it follows the override; drift guard ties
the line to the real SESSIONS_DIR + transcript sources.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ericleepi314 ericleepi314 merged commit df2d114 into main Jul 13, 2026
2 checks passed
@ericleepi314 ericleepi314 deleted the fix/session-dir-honor-config-override branch July 13, 2026 06:47
agentforce314 added a commit that referenced this pull request Jul 13, 2026
…codex paths (#710)

_prepare_subscription_request's clean() rewrote EVERY case-insensitive
"clawcodex" in the system prompt to "Claude Code" — including filesystem
paths. On Claude-subscription logins the model was told its memory lives at
~/.Claude Code/projects/<slug>/memory and its history at
~/.Claude Code/sessions — literal nonexistent locations it then searched
verbatim. This is the real source of the "guessed wrong paths" #706/#707
addressed: those fixes emit correct paths, and this rewrite corrupted them
after prompt assembly, at the provider layer.

Constrain the rewrite to standalone brand mentions: matches inside path
segments (~/.clawcodex, /etc/clawcodex), env vars ($CLAWCODEX_CONFIG_DIR),
module/file names (clawcodex_dirs), and domains (clawcodex.app) survive
verbatim. Prose disguise and the official-prefix block are unchanged.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant