fix: use config working directory for OpenAI logger path resolution in ACP mode#2675
fix: use config working directory for OpenAI logger path resolution in ACP mode#2675Mingholy merged 1 commit intoQwenLM:mainfrom
Conversation
…n ACP mode In ACP mode (e.g., Zed editor), process.cwd() may return '/' (filesystem root), causing OpenAILogger to attempt creating '/logs/openai' which fails with ENOENT. Add an optional 'cwd' parameter to OpenAILogger constructor and pass config.getWorkingDir() from LoggingContentGenerator so that log directories are resolved relative to the project working directory instead of process.cwd(). Fixes QwenLM#2671
📋 Review SummaryThis PR addresses a critical bug where 🔍 General Feedback
🎯 Specific Feedback🔵 Low
✅ Highlights
|
TLDR
Fix OpenAI logger failing to initialize in ACP mode (e.g., Zed editor) because
process.cwd()returns/(filesystem root), causingmkdir '/logs'to fail with ENOENT.Adds an optional
cwdparameter toOpenAILoggerconstructor and passesconfig.getWorkingDir()fromLoggingContentGenerator, so log directories are resolved relative to the project working directory instead ofprocess.cwd().Screenshots / Video Demo
N/A — no user-facing change in interactive CLI. This fixes an internal path resolution issue only observable in ACP mode.
Dive Deeper
Root Cause
In ACP mode (e.g., when launched by Zed editor),
process.cwd()may return/(the filesystem root). TheOpenAILoggerconstructor previously usedprocess.cwd()to build the default log directory path (logs/openai), which resolved to/logs/openai. On macOS, creating directories at the filesystem root fails withENOENT.Fix
OpenAILogger(packages/core/src/utils/openaiLogger.ts): Added an optionalcwdparameter to the constructor. When provided, it is used instead ofprocess.cwd()for resolving the default log directory and relative custom paths. Falls back toprocess.cwd()whencwdis not provided (backward compatible).LoggingContentGenerator(packages/core/src/core/loggingContentGenerator/loggingContentGenerator.ts): Passesconfig.getWorkingDir()as thecwdparameter when constructingOpenAILogger, ensuring the correct project directory is used.Changes Summary
packages/core/src/utils/openaiLogger.tscwdparam to constructorpackages/core/src/core/loggingContentGenerator/loggingContentGenerator.tsconfig.getWorkingDir()toOpenAILoggerpackages/core/src/utils/openaiLogger.test.tscwdparameter behaviorpackages/core/src/core/loggingContentGenerator/loggingContentGenerator.test.tsgetWorkingDirto config mockReviewer Test Plan
enableOpenAILogging: true)Failed to initialize OpenAI loggererror occurslogs/openai/directorynpx vitest run packages/core/src/utils/openaiLogger.test.ts packages/core/src/core/loggingContentGenerator/loggingContentGenerator.test.tsTesting Matrix
Linked issues / bugs
Fixes #2671