fix: strip CLAUDECODE env var before launching claude subprocess#12
Open
Conn-Ho wants to merge 1 commit intoryanstephen:mainfrom
Open
fix: strip CLAUDECODE env var before launching claude subprocess#12Conn-Ho wants to merge 1 commit intoryanstephen:mainfrom
Conn-Ho wants to merge 1 commit intoryanstephen:mainfrom
Conversation
When lil-agents is run inside an existing Claude Code session, ShellEnvironment captures the full login shell environment (zsh -l -i), which includes the CLAUDECODE variable. This variable is then passed to the claude subprocess, triggering Claude Code's nested-session guard: "Claude Code cannot be launched inside another Claude Code session." Fix: remove CLAUDECODE from the process environment before launching the claude subprocess so the nested-session check does not fire. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Owner
|
Hi, I can't seem to recreate the bug this is trying to fix - I can launch CC from terminal and launch lil agents from it and they respond with outputs as expected. Any more details here? |
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 lil-agents is launched from inside an existing Claude Code session (e.g. via a terminal where
CLAUDECODEis set), the app fails silently — Claude never replies.The root cause is two-layered:
ShellEnvironment.processEnvironment()runszsh -l -ito capture the user's full login shell environment, which includes theCLAUDECODEvariable set by the parent session.claudesubprocess, which triggers Claude Code's built-in nested-session guard:Fix
One line in
launchProcess()— removeCLAUDECODEfrom the environment dict before handing it to the subprocess:Reproduction
CLAUDECODEis set)With this fix, the nested-session check no longer fires regardless of how lil-agents is launched.
🤖 Generated with Claude Code