From fd6dd0c4f822d69328320a35c6448a6907b2ac3b Mon Sep 17 00:00:00 2001 From: Conn Ho <2015954952@qq.com> Date: Thu, 26 Mar 2026 14:31:34 +0800 Subject: [PATCH] fix: strip CLAUDECODE env var before launching claude subprocess 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 --- LilAgents/ClaudeSession.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/LilAgents/ClaudeSession.swift b/LilAgents/ClaudeSession.swift index 0707a91..0158b3b 100644 --- a/LilAgents/ClaudeSession.swift +++ b/LilAgents/ClaudeSession.swift @@ -57,7 +57,9 @@ class ClaudeSession: AgentSession { "--dangerously-skip-permissions" ] proc.currentDirectoryURL = FileManager.default.homeDirectoryForCurrentUser - proc.environment = ShellEnvironment.processEnvironment() + var env = ShellEnvironment.processEnvironment() + env.removeValue(forKey: "CLAUDECODE") + proc.environment = env let inPipe = Pipe() let outPipe = Pipe()