From 0df5626e7b71a71a368680c18cde4fa188f37043 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 19:01:31 +0000 Subject: [PATCH 1/2] Give a nested claude-multi its own gateway A claude-multi started inside another Multi session built its launcher environment from the inherited one, so the new gateway kept the outer session's HTTPS_PROXY (and got NODE_USE_ENV_PROXY=1 because of it) and sent provider traffic through the outer gateway. Start from withoutGateway, as the nested claude path already does. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HyhDzX8bV9EHirc6mF5QVa --- CHANGELOG.md | 8 ++++++++ plugins/multi-core/src/install/bootstrap.ts | 10 +++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e92ddc16..f1770ced 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ Entries record changes when they were made, including superseded decisions. See [ARCHITECTURE.md](ARCHITECTURE.md) for current direction and [README.md](README.md) for current capabilities. +## Unreleased + +- **A `claude-multi` started inside another Multi session uses its own gateway.** Run + from an agent's shell or a Remote Control shell, the new session's gateway inherited + the outer session's proxy setting and sent its OpenAI and other provider traffic + through the outer, possibly older, gateway. The launch now starts from the user's own + environment, as a nested `claude` already did. + ## 0.4.3 — 2026-11-27 Multi's own safety reviewer is removed; it drained the Codex quota. diff --git a/plugins/multi-core/src/install/bootstrap.ts b/plugins/multi-core/src/install/bootstrap.ts index 5bab34fa..34cac9c5 100644 --- a/plugins/multi-core/src/install/bootstrap.ts +++ b/plugins/multi-core/src/install/bootstrap.ts @@ -36,13 +36,17 @@ async function dispatch(state: Installation, args: string[], management: boolean if (manifest.name !== 'multi-core') { throw new Error('Installed core manifest does not identify multi-core'); } + // A launch from inside another Multi session (an agent's or Remote Control's shell) + // starts from the user's own environment. Otherwise the new gateway would inherit the + // outer session's HTTPS_PROXY and send its provider traffic through the outer gateway. + const own = withoutGateway(process.env); const env = withLoopbackNoProxy({ - ...process.env, - ...(state.models !== undefined && process.env.MULTI_MODELS === undefined + ...own, + ...(state.models !== undefined && own.MULTI_MODELS === undefined ? { MULTI_MODELS: state.models } : {}), // Node reads this at startup only, so the launcher process has to be started with it. - ...(needsEnvProxy(process.env) ? { NODE_USE_ENV_PROXY: '1' } : {}), + ...(needsEnvProxy(own) ? { NODE_USE_ENV_PROXY: '1' } : {}), MULTI_REAL_CLAUDE: state.claude, MULTI_ENABLED_PROVIDERS: providers.join(','), MULTI_ANTIGRAVITY: providers.includes('antigravity') ? '1' : '0', From 3ceac52832ba981a425c1f05c0bce087fa0f28c1 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 19:12:32 +0000 Subject: [PATCH 2/2] Keep the nested launch's plugin check off the outer gateway too The bootstrap's `claude plugin list --json` ran with the inherited environment, so that one startup call still went through the outer session's HTTPS_PROXY (lab test). Give it the restored environment as well. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HyhDzX8bV9EHirc6mF5QVa --- plugins/multi-core/src/install/bootstrap.ts | 16 +++++++++------- plugins/multi-core/src/install/plugins.ts | 5 ++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/plugins/multi-core/src/install/bootstrap.ts b/plugins/multi-core/src/install/bootstrap.ts index 34cac9c5..bdad98b1 100644 --- a/plugins/multi-core/src/install/bootstrap.ts +++ b/plugins/multi-core/src/install/bootstrap.ts @@ -12,20 +12,26 @@ import { } from './process.ts'; async function dispatch(state: Installation, args: string[], management: boolean) { - const { root, providers } = await installedPlugins(state.claude, settingsArguments(args)); + // A run from inside another Multi session (an agent's or Remote Control's shell) starts + // from the user's own environment. Otherwise its Claude calls and a new gateway would + // inherit the outer session's HTTPS_PROXY and go through the outer gateway. + const own = withoutGateway(process.env); + const { root, providers } = await installedPlugins(state.claude, settingsArguments(args), { + env: own, + }); if (management && args[0] === 'status') { console.log(JSON.stringify({ core: root ?? null, providers, claude: state.claude }, null, 2)); return 0; } if (!management && (!root || providers.length === 0)) { - return run(state.claude, args, { env: withoutGateway(process.env) }); + return run(state.claude, args, { env: own }); } if (!management && state.command === 'claude' && process.env.MULTI_GATEWAY_TOKEN) { // A launch command named `claude` also catches Claude's own nested runs (agents // calling `claude -p`, SDK spawns, hooks). Inside a Multi session those must // reach the real executable rather than start a second gateway, and without this // session's gateway URL and credentials: that gateway is not theirs. - return run(state.claude, args, { env: withoutGateway(process.env) }); + return run(state.claude, args, { env: own }); } if (!root) { throw new Error('Enable multi-core at user scope before using Multi commands.'); @@ -36,10 +42,6 @@ async function dispatch(state: Installation, args: string[], management: boolean if (manifest.name !== 'multi-core') { throw new Error('Installed core manifest does not identify multi-core'); } - // A launch from inside another Multi session (an agent's or Remote Control's shell) - // starts from the user's own environment. Otherwise the new gateway would inherit the - // outer session's HTTPS_PROXY and send its provider traffic through the outer gateway. - const own = withoutGateway(process.env); const env = withLoopbackNoProxy({ ...own, ...(state.models !== undefined && own.MULTI_MODELS === undefined diff --git a/plugins/multi-core/src/install/plugins.ts b/plugins/multi-core/src/install/plugins.ts index 772b98a4..2105093f 100644 --- a/plugins/multi-core/src/install/plugins.ts +++ b/plugins/multi-core/src/install/plugins.ts @@ -34,15 +34,18 @@ export function providerSelection(value: string | undefined): string[] | undefin export async function installedPlugins( claude: string, settingsArgs: string[] = [], - options: { platform?: NodeJS.Platform } = {}, + options: { platform?: NodeJS.Platform; env?: NodeJS.ProcessEnv } = {}, ) { const platform = options.platform ?? process.platform; + const env = options.env ?? process.env; const invocation = executableInvocation( claude, [...settingsArgs, 'plugin', 'list', '--json'], platform, + env, ); const { stdout } = await promisify(execFile)(invocation.command, invocation.args, { + env, timeout: 15000, maxBuffer: 4 * 1024 * 1024, encoding: 'utf8',