fix(prompt): name ~/.clawcodex in # Environment so the model finds session history#706
Merged
Merged
Conversation
…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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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→.clawcodexrebrand (#678) broke the model's trained-in assumption about where session data lives, and the# Environmentsystem-prompt block never named the new root. Nothing in source emits a.claudesession path — it was pure guessing. (Notably, the model already guessed thesessionssubdir correctly; only the root was wrong.)Fix
Add one constant line to the
# Environmentsection naming clawcodex's data directory and steering off~/.claude:Wired into both
_build_env_section(the live agent-server TUI / headless-p/ engine-REPL path viabuild_effective_system_prompt) and the simplified_compute_env_info.Why anchor on
Path.home()/".clawcodex"(notget_user_config_dir())sessions/andtranscripts/are hardcoded to~/.clawcodexin ~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.Tests
~/.clawcodexwith the override set/unset; never leaks the override root).services.session_storage.SESSIONS_DIRand the transcripts source, so a future re-home fails loudly.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_DIRfor consistency with the other subsystems.🤖 Generated with Claude Code