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 <noreply@anthropic.com>
This commit is contained in:
chungyeong
2026-03-13 23:05:16 +09:00
parent 290eace01b
commit d5fcc258b7

View File

@@ -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: