fix(ralph-wiggum): isolate ralph-loop state per session#26077
Open
RooseveltAdvisors wants to merge 1 commit intoanthropics:mainfrom
Open
fix(ralph-wiggum): isolate ralph-loop state per session#26077RooseveltAdvisors wants to merge 1 commit intoanthropics:mainfrom
RooseveltAdvisors wants to merge 1 commit intoanthropics:mainfrom
Conversation
…oss-session interference
When multiple Claude Code sessions are open in the same project, the
shared state file (.claude/ralph-loop.local.md) causes the stop hook
to hijack unrelated sessions into the ralph loop.
Fix by making state files session-specific:
- Add SessionStart hook that captures session_id via CLAUDE_ENV_FILE
- Setup script creates .claude/ralph-loop.{SESSION_ID}.local.md
- Stop hook extracts session_id from hook input JSON, only processes
matching state file
- Update cancel-ralph to handle session-specific and legacy filenames
Co-Authored-By: Claude Opus 4.6 <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.
Summary
.claude/ralph-loop.local.md) that caused unrelated sessions to get hijacked into the loop when they tried to exitChanges
SessionStarthook (session-start-hook.sh): Capturessession_idfrom hook input and exports it asCLAUDE_SESSION_IDviaCLAUDE_ENV_FILE, making it available to bash commands.claude/ralph-loop.{SESSION_ID}.local.mdinstead of the shared filenamesession_idfrom its JSON input and only looks for the matching state file — other sessions' loops are invisibleHow it works
.claude/ralph-loop.local.md.claude/ralph-loop.abc123.local.md.claude/ralph-loop.xyz789.local.md→ not found → exits normallyTest plan
/ralph-loop "test task" --max-iterations 5)/cancel-ralphworks in the session that started the loopCLAUDE_SESSION_IDis unavailable (new session before restart)🤖 Generated with Claude Code