From d5fcc258b7cb127c6fe6f68ebe03d9958ef69144 Mon Sep 17 00:00:00 2001 From: chungyeong Date: Fri, 13 Mar 2026 23:05:16 +0900 Subject: [PATCH] fix: unset CLAUDECODE env var to allow nested Claude subprocess calls Claude Code refuses to launch inside another Claude Code session. Strip the CLAUDECODE marker from the inherited environment so that cross-eval can spawn Claude as a subprocess from within Claude Code. Co-Authored-By: Claude Opus 4.6 --- cross_eval/runtime_env.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cross_eval/runtime_env.py b/cross_eval/runtime_env.py index caa5a77..6e5cc62 100644 --- a/cross_eval/runtime_env.py +++ b/cross_eval/runtime_env.py @@ -94,6 +94,9 @@ def build_runtime_environment( ) -> tuple[dict[str, str], list[Path], dict[str, str]]: """Build subprocess env plus metadata about loaded files and names.""" env = os.environ.copy() if execution.inherit_env else {} + # Remove CLAUDECODE to avoid "nested session" errors when spawning + # Claude Code as a subprocess from within a Claude Code session. + env.pop("CLAUDECODE", None) loaded_files = resolve_env_files(execution, project_root) loaded_values: dict[str, str] = {} for path in loaded_files: