agentHost: forward parent --user-data-dir to spawned host#313827
Merged
Conversation
The local agent host starters (Electron utility process and Node child
process) only forwarded --logsPath. Inside agentHostMain.ts, parseArgs
therefore never saw --user-data-dir, so the agent host's
NativeEnvironmentService always resolved userDataPath to the platform
default for the build's quality.
As a result, all agent host state -- SessionDataService
({userData}/agentSessionData), AgentPluginManager
({userData}/agentPlugins), and the root agent-host-config.json under
appSettingsHome -- was written to the default location instead of the
custom user data dir the parent app was launched with.
Forward the parent process's resolved userDataPath to the child as
--user-data-dir so the child's parseArgs picks it up and all derived
paths live inside the custom dir.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR ensures the locally spawned agent host process (utility process and Node child-process fallback) uses the same user data directory as the parent application by forwarding the parent’s resolved userDataPath via --user-data-dir. This aligns the agent host’s NativeEnvironmentService-derived paths with the parent when the parent is launched with a custom --user-data-dir.
Changes:
- Forward
--user-data-dir <parent userDataPath>to the spawned agent host in the Node child-process starter. - Forward
--user-data-dir <parent userDataPath>to the spawned agent host in the Electron utility-process starter.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/agentHost/node/nodeAgentHostStarter.ts | Adds --user-data-dir forwarding to the child-process agent host argv. |
| src/vs/platform/agentHost/electron-main/electronAgentHostStarter.ts | Adds --user-data-dir forwarding to the utility-process agent host argv. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 0
justschen
approved these changes
May 2, 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.
What
The local agent host starters —
ElectronAgentHostStarter(utility process) andNodeAgentHostStarter(child process fallback) — only forwarded--logsPathto the spawned host. They now also forward the parent's resolveduserDataPathas--user-data-dir.Why
Inside
agentHostMain.ts, the agent host builds its ownNativeEnvironmentServicefromparseArgs(process.argv, OPTIONS). Without--user-data-diron the command line, that resolves to the platform default for the build's quality (e.g.~/Library/Application Support/agents-oss-dev) regardless of what the parent app was launched with.That meant all agent host state was being written to the wrong place when the parent was started with a custom
--user-data-dir:SessionDataService→{userData}/agentSessionData/{sessionId}/AgentPluginManager→{userData}/agentPlugins/{key}/{userData}/User/globalStorage/agent-host-config.jsonNote: Electron propagates
--user-data-dirto its own child processes forapp.getPath('userData'), but ourparseArgs-deriveduserDataPathis independent of that and needs the arg explicitly.Notes for reviewers
--logsPath), rather than introducing a new payload-style config (asSharedProcessandlocalProcessExtensionHostdo).--user-data-dir— the resolved path is the same default the child would have picked on its own.(Written by Copilot)