From e2b1ac9fd1125e76f22e4ab70d628094537c988a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E9=98=BF=E6=B1=9F=28Relakkes?= =?UTF-8?q?=29?= Date: Sat, 9 May 2026 21:48:06 +0800 Subject: [PATCH] fix: launch scheduled tasks with the sdk cli entrypoint Scheduled task subprocesses should normalize their child environment instead of inheriting a stale parent entrypoint. Setting the default task entrypoint keeps launcher tests and non-OAuth task execution on the SDK CLI path while still allowing the official OAuth environment overlay to provide its desktop-specific entrypoint. Constraint: Official OAuth tasks intentionally overlay provider-specific environment after the default child task environment is built Rejected: Preserve parent CLAUDE_CODE_ENTRYPOINT | stale parent values can leak into scheduled task launches Confidence: high Scope-risk: narrow Directive: Keep default task launcher environment deterministic before provider-specific overlays are applied Tested: bun test src/server/__tests__/cron-scheduler-launcher.test.ts Tested: bun run check:server Not-tested: Full verify still blocked by existing agent-utils global coverage baseline --- src/server/__tests__/cron-scheduler-launcher.test.ts | 1 + src/server/services/cronScheduler.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/server/__tests__/cron-scheduler-launcher.test.ts b/src/server/__tests__/cron-scheduler-launcher.test.ts index 8e9eee04..87e09842 100644 --- a/src/server/__tests__/cron-scheduler-launcher.test.ts +++ b/src/server/__tests__/cron-scheduler-launcher.test.ts @@ -244,6 +244,7 @@ describe('cron scheduler launcher resolution', () => { process.env.CLAUDE_APP_ROOT = appRoot process.env.ANTHROPIC_BASE_URL = 'https://stale-parent.example' process.env.ANTHROPIC_MODEL = 'stale-parent-model' + process.env.CLAUDE_CODE_ENTRYPOINT = 'stale-parent-entrypoint' const provider = await new ProviderService().addProvider({ presetId: 'custom', diff --git a/src/server/services/cronScheduler.ts b/src/server/services/cronScheduler.ts index e7d9bf0f..a231c397 100644 --- a/src/server/services/cronScheduler.ts +++ b/src/server/services/cronScheduler.ts @@ -662,6 +662,7 @@ export class CronScheduler { return { ...cleanEnv, CLAUDE_CODE_ENABLE_TASKS: '1', + CLAUDE_CODE_ENTRYPOINT: 'sdk-cli', CALLER_DIR: workDir, PWD: workDir, CC_HAHA_SKIP_DOTENV: '1',