From a4f024c04797a9e27dbd32905047d7709f7e5d9a Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Wed, 8 Apr 2026 16:10:21 +0800 Subject: [PATCH] fix: remove inherited CLAUDECODE env to prevent nested session crash When OpenAlice is launched from within a Claude Code terminal, the CLAUDECODE environment variable is inherited by the Agent SDK subprocess, causing Claude Code to reject execution with "cannot be launched inside another Claude Code session" (exit code 1). Co-Authored-By: Claude Opus 4.6 (1M context) --- src/ai-providers/agent-sdk/query.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ai-providers/agent-sdk/query.ts b/src/ai-providers/agent-sdk/query.ts index d4ce05d1..7a1dac3f 100644 --- a/src/ai-providers/agent-sdk/query.ts +++ b/src/ai-providers/agent-sdk/query.ts @@ -122,6 +122,8 @@ export async function askAgentSdk( const isOAuthMode = loginMethod === 'claudeai' const env: Record = { ...process.env } + // Prevent "nested session" detection when launched from within Claude Code + delete env.CLAUDECODE if (isOAuthMode) { // Force OAuth by removing any inherited API key delete env.ANTHROPIC_API_KEY