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
This commit is contained in:
程序员阿江(Relakkes) 2026-05-09 21:48:06 +08:00
parent 571d771025
commit e2b1ac9fd1
2 changed files with 2 additions and 0 deletions

View File

@ -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',

View File

@ -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',