Skip to content

agentHost: forward parent --user-data-dir to spawned host#313827

Merged
roblourens merged 1 commit into
mainfrom
roblou/agents/custom-user-data-dir-support
May 2, 2026
Merged

agentHost: forward parent --user-data-dir to spawned host#313827
roblourens merged 1 commit into
mainfrom
roblou/agents/custom-user-data-dir-support

Conversation

@roblourens
Copy link
Copy Markdown
Member

What

The local agent host starters — ElectronAgentHostStarter (utility process) and NodeAgentHostStarter (child process fallback) — only forwarded --logsPath to the spawned host. They now also forward the parent's resolved userDataPath as --user-data-dir.

Why

Inside agentHostMain.ts, the agent host builds its own NativeEnvironmentService from parseArgs(process.argv, OPTIONS). Without --user-data-dir on 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}/
  • Root agent host config → {userData}/User/globalStorage/agent-host-config.json

Note: Electron propagates --user-data-dir to its own child processes for app.getPath('userData'), but our parseArgs-derived userDataPath is independent of that and needs the arg explicitly.

Notes for reviewers

  • This matches the existing convention in both starters of forwarding flags via argv (alongside --logsPath), rather than introducing a new payload-style config (as SharedProcess and localProcessExtensionHost do).
  • No change to behavior when the parent is launched without --user-data-dir — the resolved path is the same default the child would have picked on its own.

(Written by Copilot)

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>
Copilot AI review requested due to automatic review settings May 2, 2026 00:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@roblourens roblourens marked this pull request as ready for review May 2, 2026 00:16
@roblourens roblourens enabled auto-merge (squash) May 2, 2026 00:16
@roblourens roblourens merged commit f6c05d7 into main May 2, 2026
30 checks passed
@roblourens roblourens deleted the roblou/agents/custom-user-data-dir-support branch May 2, 2026 00:49
@vs-code-engineering vs-code-engineering Bot added this to the 1.119.0 milestone May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants