feat(storage): support configurable runtime output directory#2127
Open
yiliang114 wants to merge 2 commits intoQwenLM:mainfrom
Open
feat(storage): support configurable runtime output directory#2127yiliang114 wants to merge 2 commits intoQwenLM:mainfrom
yiliang114 wants to merge 2 commits intoQwenLM:mainfrom
Conversation
…2014) Add `advanced.runtimeOutputDir` setting and `QWEN_RUNTIME_DIR` env var to redirect runtime output (temp files, debug logs, session data, todos, insights) to a custom directory while keeping config files at ~/.qwen. - Introduce `Storage.setRuntimeBaseDir()` / `getRuntimeBaseDir()` with tilde expansion and relative path resolution - Add `AsyncLocalStorage`-based `runWithRuntimeBaseDir()` for concurrent session isolation in ACP integration - Update all runtime path methods to use `getRuntimeBaseDir()` instead of `getGlobalQwenDir()` (temp, debug, ide, projects, history dirs) - Config paths (settings, oauth, installation_id, etc.) remain pinned to `~/.qwen` regardless of runtime dir configuration - Add comprehensive tests covering path resolution, env var priority, async context isolation, and config path stability
Contributor
📋 Review SummaryThis PR introduces a configurable runtime output directory feature, allowing users to redirect temporary files, debug logs, and other runtime data to a custom location via settings or environment variables. The implementation is well-architected with proper path resolution, tilde expansion, and async context isolation for concurrent sessions. 🔍 General Feedback
🎯 Specific Feedback🟡 High
🟢 Medium
🔵 Low
✅ Highlights
|
This was referenced Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Support configurable runtime output directory, allowing users to redirect runtime output (temp files, debug logs, session data, todos, insights, etc.) to a custom directory via the
advanced.runtimeOutputDirsetting or theQWEN_RUNTIME_DIRenvironment variable, while config files (settings.json, oauth, installation_id, etc.) remain at~/.qwen.This is an initial implementation for issue #2014, providing flexible runtime output path management for enterprise Agent deployment scenarios.
Dive Deeper
Core Design
Storageclass extensions (packages/core/src/config/storage.ts):setRuntimeBaseDir()/getRuntimeBaseDir()static methods~) expansion and relative path resolution (with optional cwd base directory)QWEN_RUNTIME_DIRenv var >setRuntimeBaseDir()value >getGlobalQwenDir()defaultAsyncLocalStorageto implementrunWithRuntimeBaseDir()for isolating runtime paths across concurrent ACP sessionsPath classification:
getRuntimeBaseDir()):tmp/,debug/,ide/,projects/,history/,todos/,insights/~/.qwen):settings.json,oauth_creds.json,installation_id,google_accounts.json,mcp-oauth-tokens.json,commands/,memory.md,bin/,skills/Settings integration (
packages/cli/src/config/settingsSchema.ts+config.ts):runtimeOutputDirstring setting under theadvancedcategoryloadCliConfig()callsStorage.setRuntimeBaseDir()during initializationACP session isolation (
packages/cli/src/acp-integration/session/Session.ts):Sessionsnapshots the currentruntimeBaseDirat construction timeprompt()wraps execution inStorage.runWithRuntimeBaseDir()to ensure concurrent sessions have isolated pathsAdapted modules:
StaticInsightGenerator: insight output directoryinsightCommand: projects directory lookuptodoWrite: todo file read/writeTest Coverage
storage.test.ts: Path resolution, env var priority, tilde expansion, relative paths, null/undefined/empty string reset, runtime path methods, config path stability, AsyncLocalStorage concurrent isolationconfig.test.ts:loadCliConfigruntimeOutputDir settings integrationSession.test.ts: ACP sessionrunWithRuntimeBaseDirinvocation verificationStaticInsightGenerator.test.ts: Insight output uses runtime directoryinsightCommand.test.ts: Insight command uses runtime directorytodoWrite.test.ts: Todo read/write uses runtime directoryReviewer Test Plan
npm run testto confirm all tests pass~/.qwen/settings.json:{ "advanced": { "runtimeOutputDir": "/tmp/qwen-runtime-test" } }/tmp/qwen-runtime-test/QWEN_RUNTIME_DIR=/tmp/qwen-env-testand verify the env var takes priority over the setting~/.qwen/settings.jsonand other config files are unaffected~/.qwendirectoryTesting Matrix
Linked issues / bugs
Closes #2014