From 74377fafeec54a5d083c591c0dc51c2af3e5e99f Mon Sep 17 00:00:00 2001 From: Haoqing Wang <78337154+hqhq1025@users.noreply.github.com> Date: Tue, 14 Apr 2026 13:29:05 +0800 Subject: [PATCH] fix(cli): prevent CLAUDE_CODE_ENTRYPOINT leak into local spawn (#452) extractSDKMetadataAsync() calls query() which sets CLAUDE_CODE_ENTRYPOINT='sdk-ts' on the current process env. When claudeLocal() later spawns the claude CLI, the child inherits this env var, causing Claude Code to treat the session as SDK-launched. This makes the session invisible to `claude --resume`. Strip CLAUDE_CODE_ENTRYPOINT from the child env so the local spawn uses its own default entrypoint. Closes #450 --- cli/src/claude/claudeLocal.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cli/src/claude/claudeLocal.ts b/cli/src/claude/claudeLocal.ts index f6f4fbeb..04edc2ee 100644 --- a/cli/src/claude/claudeLocal.ts +++ b/cli/src/claude/claudeLocal.ts @@ -76,8 +76,15 @@ export async function claudeLocal(opts: { // Prepare environment variables // Note: Local mode uses global Claude installation + // + // SDK metadata extraction (extractSDKMetadataAsync → query()) sets + // CLAUDE_CODE_ENTRYPOINT='sdk-ts' on the current process. If leaked + // into the local spawn, Claude Code thinks it was SDK-launched and + // excludes the session from `claude --resume`. Destructure it out + // so the child uses its own default entrypoint. + const { CLAUDE_CODE_ENTRYPOINT: _, ...cleanEnv } = process.env const env = { - ...process.env, + ...cleanEnv, DISABLE_AUTOUPDATER: '1', ...opts.claudeEnvVars }