Skip to content

fix(prompt): name ~/.clawcodex in # Environment so the model finds session history#706

Merged
ericleepi314 merged 1 commit into
mainfrom
fix/env-section-session-dir
Jul 13, 2026
Merged

fix(prompt): name ~/.clawcodex in # Environment so the model finds session history#706
ericleepi314 merged 1 commit into
mainfrom
fix/env-section-session-dir

Conversation

@ericleepi314

Copy link
Copy Markdown
Collaborator

Problem

When the user asked their running clawcodex to check the previous session history (e.g. "show the links from the last websearch"), the model wasted turns guessing wrong paths — /Users/…/.Claude Code/sessions (nonexistent), ~/.claude/ (the real Claude Code CLI's directory, a different tool). The .claude.clawcodex rebrand (#678) broke the model's trained-in assumption about where session data lives, and the # Environment system-prompt block never named the new root. Nothing in source emits a .claude session path — it was pure guessing. (Notably, the model already guessed the sessions subdir correctly; only the root was wrong.)

Fix

Add one constant line to the # Environment section naming clawcodex's data directory and steering off ~/.claude:

clawcodex data directory: ~/.clawcodex — this tool's previous session history and transcripts live in the sessions/ and transcripts/ subdirectories here, NOT under ~/.claude (which belongs to a different tool)

Wired into both _build_env_section (the live agent-server TUI / headless -p / engine-REPL path via build_effective_system_prompt) and the simplified _compute_env_info.

Why anchor on Path.home()/".clawcodex" (not get_user_config_dir())

sessions/ and transcripts/ are hardcoded to ~/.clawcodex in ~10 writers and deliberately do not honor $CLAWCODEX_CONFIG_DIR, whereas config/memory/skills do. Anchoring on the override root would make the line state a wrong path authoritatively whenever the override is set — strictly worse than the guessing it replaces. Path.home()/".clawcodex" is their invariant location in both default and override configs.

  • Cache-safe: constant per process → byte-stable on the REQUEST cache prefix (no Anthropic/DeepSeek caching regression).

Tests

  • Override-invariance (names ~/.clawcodex with the override set/unset; never leaks the override root).
  • Drift guard tying the named root to the real services.session_storage.SESSIONS_DIR and the transcripts source, so a future re-home fails loudly.
  • End-to-end live-prompt assertion + cache-stability pin.
  • 195 passed across prompt/context/cache suites; 0 regressions.

Reviewed via the Critic loop (caught the override false-path in review) → APPROVE.

Follow-up (separate PR): re-home sessions/transcripts to honor $CLAWCODEX_CONFIG_DIR for consistency with the other subsystems.

🤖 Generated with Claude Code

…ssion history

When asked to check previous session history, the agent guessed ~/.claude
(the real Claude Code harness's dir) or a mangled ~/.Claude Code/sessions and
wasted turns — the .claude→.clawcodex rebrand broke the model's trained-in
prior and the # Environment block never named clawcodex's own data root.

Add a constant line to the env section (both _build_env_section, the live
agent-server/headless/REPL path, and the simplified _compute_env_info) naming
the clawcodex data directory and steering off ~/.claude.

Anchor on Path.home()/".clawcodex" (NOT get_user_config_dir()): sessions/ and
transcripts/ are hardcoded there and deliberately ignore $CLAWCODEX_CONFIG_DIR,
so this is their invariant location in both default and override configs —
anchoring on the override root would authoritatively misdirect the model
whenever it's set. The line is constant per process, so it stays byte-stable
on the REQUEST cache prefix (no caching regression).

Tests: override-invariance, a drift guard tying the named root to the real
SESSIONS_DIR + transcripts sources, an end-to-end live-prompt assertion, and a
cache-stability pin.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ericleepi314 ericleepi314 merged commit 3fcec2a into main Jul 13, 2026
2 checks passed
@ericleepi314 ericleepi314 deleted the fix/env-section-session-dir branch July 13, 2026 06:26
ericleepi314 added a commit that referenced this pull request Jul 13, 2026
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>
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