#7404 · Host-managed routing drops settings-sourced model overrides
Verdict: REPRODUCED · Root-cause confidence: high · reproduction label: confirmed-repro
1. TL;DR
Account Pooler marks Claude Code sessions as host-managed to keep them away from the machine’s personal login. Claude Code also uses that marker to reject model-routing environment variables loaded from local settings. A credential-free local API fixture reproduced the effect with the repository-pinned Claude Code binary: a subagent inherited the parent model instead of the configured override. Moving the override into the process environment restored the selected subagent model. The rejected setting produced a debug-log warning but no warning in the CLI’s normal JSON output or stderr.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| Pooled sessions receive the host-managed marker. | Verified | Production contribution at server.ts:373 and the existing routing/bypass integration test. |
| Local settings cannot select the implicit subagent model under the marker. | Verified | Unmanaged local settings and managed process environment produced Sonnet + Haiku requests; managed local settings produced Sonnet requests only. Each subagent case completed at least three API requests. |
| The main-model environment override is also affected. | Verified | The fixture observed Haiku without the marker, a different default model with it, and Haiku again using process environment. |
| The notice is not normally visible. | Verified at CLI boundary | Ignored-setting messages appeared in the explicit debug log, not stdout or stderr. BB’s stderr handler only retains an error tail. |
| All listed model variables, including the Workflow variant, behave identically. | Not established | The pinned binary is 2.1.318, not the reported 2.1.322. The Workflow variable was included but did not emit the same ignored-variable warning. No Workflow execution was performed. |
| User-global settings and machine-env configuration work end to end. | Unverified | No user-global settings, real accounts, production thread, or machine configuration was accessed. The process-env control is verified only in the isolated CLI. |
3. Environment
- Public repository
get-bb/bb; commit9816b9420d76b47c3cbff99fcc620c38527f0388, fetched directly from the trusted origin. - Linux x86_64; Node v22.19.0; SDK 0.3.318; its lockfile-pinned linux-x64 CLI reports
2.1.318 (Claude Code). - Two clean temporary clones, called
baseandverify, at the same recorded commit. Both completed frozen dependency installation. No dependency was added. - Every case binds a new loopback HTTP fixture with
listen(0)and creates a new temporary project and HOME. The child environment is an explicit allowlist with a non-credential fixture string. All completions are local deterministic SSE responses; no paid model request is needed. - No BB app, host daemon, production data directory, or real pool was started. Fixture sockets and temporary directories are removed in
finally.
4. Minimal reproduction
- Clone trusted main and install its frozen dependencies:
git clone https://github.com/get-bb/bb.git bb-7404 cd bb-7404 git checkout --detach 9816b9420d76b47c3cbff99fcc620c38527f0388 pnpm install --frozen-lockfile --prefer-offline
- Save the complete reproduction source printed in this report as
settings-routing.mjsoutside the checkout, then run it against that checkout:node /path/to/settings-routing.mjs /path/to/bb-7404
The script resolves the native Claude binary from the repository’s pinned SDK dependency, never from the user’s PATH. It creates its own settings fixture from the independently inspected provider behavior. - Compare the unmanaged local-settings, managed local-settings, and managed process-env cases. The API fixture emits exactly one Agent call, with no explicit model, then returns plain text. The expected preserved-setting behavior is Sonnet for the parent and Haiku for the subagent in all three cases. Actual request models:
subagent-local-settings-unmanaged: ["claude-sonnet-4-5","claude-haiku-4-5"] subagent-local-settings-managed: ["claude-sonnet-4-5"] subagent-process-env-managed: ["claude-sonnet-4-5","claude-haiku-4-5"]
- Enable the proposed behavior assertion to obtain a failing regression against unchanged main:
node /path/to/settings-routing.mjs /path/to/bb-7404 --expect-preserved AssertionError [ERR_ASSERTION]: Host-managed sessions must preserve settings-sourced model selection 2 !== 0
This assertion fails deliberately on the real ignored-setting count, not on a simulated implementation. No production fix was applied. The diagnostic shown here is transcribed from the recorded expected failure; raw evidence remains in the local report backup.
First-run output
{"name":"local-settings-unmanaged","status":0,"models":["claude-haiku-4-5"],"ignored":[],"debugWarnings":[],"visibleWarning":false}
{"name":"local-settings-managed","status":0,"models":["claude-opus-5-5"],"ignored":["ANTHROPIC_MODEL","CLAUDE_CODE_SUBAGENT_MODEL"],"debugWarnings":["Ignoring ANTHROPIC_MODEL from localSettings — this session's provider routing is managed by the host (CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST or a host-auth-callback marker), so settings-sourced provider/auth configuration does not apply.","Ignoring CLAUDE_CODE_SUBAGENT_MODEL from localSettings — this session's provider routing is managed by the host (CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST or a host-auth-callback marker), so settings-sourced provider/auth configuration does not apply."],"visibleWarning":false}
{"name":"process-env-managed","status":0,"models":["claude-haiku-4-5"],"ignored":[],"debugWarnings":[],"visibleWarning":false}
{"name":"subagent-local-settings-unmanaged","status":0,"models":["claude-sonnet-4-5","claude-haiku-4-5"],"ignored":[],"debugWarnings":[],"visibleWarning":false}
{"name":"subagent-local-settings-managed","status":0,"models":["claude-sonnet-4-5"],"ignored":["ANTHROPIC_MODEL","CLAUDE_CODE_SUBAGENT_MODEL"],"debugWarnings":["Ignoring ANTHROPIC_MODEL from localSettings — this session's provider routing is managed by the host (CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST or a host-auth-callback marker), so settings-sourced provider/auth configuration does not apply.","Ignoring CLAUDE_CODE_SUBAGENT_MODEL from localSettings — this session's provider routing is managed by the host (CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST or a host-auth-callback marker), so settings-sourced provider/auth configuration does not apply."],"visibleWarning":false}
{"name":"subagent-process-env-managed","status":0,"models":["claude-sonnet-4-5","claude-haiku-4-5"],"ignored":[],"debugWarnings":[],"visibleWarning":false}
PASS: host-managed settings filtering reproduced without real credentials or remote API calls
Complete reproduction source
import assert from 'node:assert/strict';
import { spawn } from 'node:child_process';
import { createServer } from 'node:http';
import { mkdtemp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
import { createRequire } from 'node:module';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
const checkout = resolve(process.argv[2] ?? '.');
const require = createRequire(join(checkout, 'plugins/provider-claude-code/package.json'));
const sdkRequire = createRequire(require.resolve('@anthropic-ai/claude-agent-sdk'));
const executable = sdkRequire.resolve('@anthropic-ai/claude-agent-sdk-linux-x64/claude');
const configuredModel = 'claude-haiku-4-5';
const modelEnv = {
ANTHROPIC_MODEL: configuredModel,
CLAUDE_CODE_SUBAGENT_MODEL: configuredModel,
CLAUDE_CODE_WORKFLOW_SUBAGENT_MODEL: configuredModel,
};
async function runCase(name, managed, source, delegate = false) {
const scratch = await mkdtemp(join(tmpdir(), 'bb-routing-repro-'));
const models = [];
const server = createServer(async (request, response) => {
let body = '';
for await (const chunk of request) body += chunk;
if (!request.url?.includes('/messages')) {
response.writeHead(200, { 'content-type': 'application/json' });
response.end('{}');
return;
}
const payload = JSON.parse(body);
models.push(payload.model);
const message = {
id: 'msg_fixture', type: 'message', role: 'assistant', model: payload.model,
content: [], stop_reason: null, stop_sequence: null,
usage: { input_tokens: 1, output_tokens: 1 },
};
response.writeHead(200, { 'content-type': 'text/event-stream' });
const delegation = delegate && models.length === 1;
const content = delegation
? { type: 'tool_use', id: 'toolu_fixture', name: 'Agent', input: {} }
: { type: 'text', text: '' };
for (const event of [
{ type: 'message_start', message },
{ type: 'content_block_start', index: 0, content_block: content },
{ type: 'content_block_delta', index: 0, delta: delegation
? { type: 'input_json_delta', partial_json: JSON.stringify({ subagent_type: 'general-purpose', description: 'Reply check', prompt: 'Return ok.' }) }
: { type: 'text_delta', text: 'ok' } },
{ type: 'content_block_stop', index: 0 },
{ type: 'message_delta', delta: { stop_reason: delegation ? 'tool_use' : 'end_turn', stop_sequence: null }, usage: { output_tokens: 1 } },
{ type: 'message_stop' },
]) response.write(`event: ${event.type}\ndata: ${JSON.stringify(event)}\n\n`);
response.end();
});
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
const address = server.address();
assert(address && typeof address !== 'string');
try {
await mkdir(join(scratch, '.claude'));
await mkdir(join(scratch, 'home'));
if (source === 'settings') {
await writeFile(join(scratch, '.claude/settings.local.json'), JSON.stringify({ env: modelEnv }));
}
const debugFile = join(scratch, 'debug.log');
const child = spawn(executable, [
'-p', '--output-format', 'json', '--tools', delegate ? 'Agent' : '',
...(delegate ? ['--allowedTools', 'Agent', '--model', 'claude-sonnet-4-5'] : []),
'--setting-sources', 'local',
'--debug-file', debugFile, 'Return ok.',
], {
cwd: scratch,
env: {
PATH: '/usr/bin:/bin', HOME: join(scratch, 'home'),
CLAUDE_CONFIG_DIR: join(scratch, 'home/.claude'),
ANTHROPIC_BASE_URL: `http://127.0.0.1:${address.port}`,
ANTHROPIC_AUTH_TOKEN: 'fixture-not-a-credential',
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1', DISABLE_AUTOUPDATER: '1',
...(managed ? { CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST: '1' } : {}),
...(source === 'process' ? modelEnv : {}),
},
stdio: ['ignore', 'pipe', 'pipe'],
});
let stdout = '';
let stderr = '';
child.stdout.on('data', chunk => { stdout += chunk; });
child.stderr.on('data', chunk => { stderr += chunk; });
const timeout = setTimeout(() => child.kill('SIGKILL'), 30000);
const status = await new Promise((resolve, reject) => {
child.on('error', reject);
child.on('close', resolve);
}).finally(() => clearTimeout(timeout));
const debug = await readFile(debugFile, 'utf8').catch(() => '');
const ignored = Object.keys(modelEnv).filter(key => debug.includes(`Ignoring ${key} from localSettings`));
const debugWarnings = debug.split('\n').filter(line => /Ignoring (ANTHROPIC_MODEL|CLAUDE_CODE_SUBAGENT_MODEL|CLAUDE_CODE_WORKFLOW_SUBAGENT_MODEL) from localSettings/.test(line)).map(line => line.replace(/^.*?Ignoring /, 'Ignoring '));
const result = { name, status, models: [...new Set(models)], ignored, debugWarnings,
visibleWarning: /Ignoring (ANTHROPIC_MODEL|CLAUDE_CODE_SUBAGENT_MODEL|CLAUDE_CODE_WORKFLOW_SUBAGENT_MODEL)/.test(stdout + stderr) };
console.log(JSON.stringify(result));
assert.equal(status, 0, `CLI did not finish: ${stderr.slice(-1000)} ${stdout.slice(-1000)}`);
assert(models.length > 0, 'The CLI did not reach the local API fixture');
if (managed && source === 'settings') {
assert(ignored.includes('CLAUDE_CODE_SUBAGENT_MODEL'));
assert(ignored.includes('ANTHROPIC_MODEL'));
assert(!models.includes(configuredModel));
assert.equal(result.visibleWarning, false);
if (process.argv.includes('--expect-preserved')) assert.equal(ignored.length, 0, 'Host-managed sessions must preserve settings-sourced model selection');
} else {
assert.equal(ignored.length, 0);
assert(models.includes(configuredModel));
}
if (delegate) assert(models.length >= 3, 'The fixture did not complete a subagent and parent continuation');
} finally {
server.closeAllConnections();
await new Promise(resolve => server.close(resolve));
await rm(scratch, { recursive: true, force: true });
}
}
await runCase('local-settings-unmanaged', false, 'settings');
await runCase('local-settings-managed', true, 'settings');
await runCase('process-env-managed', true, 'process');
await runCase('subagent-local-settings-unmanaged', false, 'settings', true);
await runCase('subagent-local-settings-managed', true, 'settings', true);
await runCase('subagent-process-env-managed', true, 'process', true);
console.log('PASS: host-managed settings filtering reproduced without real credentials or remote API calls');
5. Root cause
Account Pooler’s provider-environment contribution always supplies CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1 while routing Claude. The adjacent rationale is prevention of personal-login refresh-token consumption. This is an authentication-isolation measure, not a model setting.
name: "CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST", value: "1", reason: "Claude Code otherwise refreshes this machine's own Claude login while routed, which can spend its single-use refresh token and sign it out",
The provider’s session-options builder preserves the supplied process environment; it does not promote project settings env into it. SDK startup asks Claude to load user, project, and local settings and passes that environment unchanged.
settingSources: ["user", "project", "local"], persistSession: true, env: this.options.env ?? process.env, stderr: onStderr,
The isolated real-CLI experiment establishes the downstream policy: settings-sourced ANTHROPIC_MODEL and CLAUDE_CODE_SUBAGENT_MODEL are rejected when the marker is set; process-env equivalents are honored. The loss occurs in Claude’s settings application, not because BB rewrites the requested subagent model. The stderr callback only buffers text for errors; the observed ignored-setting warnings do not even reach that callback because they are debug-only.
Provider settings expose subagent and Workflow enable/disable switches, but no corresponding model-default replacement. The pool routing documentation explains the login-isolation flag, not this model-setting side effect.
6. Proposed fix and safety decision
Preserve the host-managed authentication marker. Choose and document a supported model-default configuration path with explicit precedence; alternatively surface an actionable ignored-settings notice. Any bridge from settings-file env into process env must be narrowly reviewed so it cannot promote provider/auth routing overrides across the host-managed boundary. A blanket settings-env merge or removal of the marker is not safe.
No automatic fix PR: the remedy requires a product decision about model configuration and precedence, and the tempting flag-removal shortcut changes an authentication boundary. These fail the autopilot simple-fix conditions even though the reproduction is conclusive. No fix branch, production change, or push to the target repository was made.
7. Verification
The same agent repeated all six cases in a second clean temporary clone at the recorded commit, with freshly installed frozen dependencies, new temporary project directories, and newly allocated loopback ports. The full second run passed and produced the same model sets and ignored variables. This is a repeated clean run, not independent verification. The complete second-run output follows.
{"name":"local-settings-unmanaged","status":0,"models":["claude-haiku-4-5"],"ignored":[],"debugWarnings":[],"visibleWarning":false}
{"name":"local-settings-managed","status":0,"models":["claude-opus-5-5"],"ignored":["ANTHROPIC_MODEL","CLAUDE_CODE_SUBAGENT_MODEL"],"debugWarnings":["Ignoring ANTHROPIC_MODEL from localSettings — this session's provider routing is managed by the host (CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST or a host-auth-callback marker), so settings-sourced provider/auth configuration does not apply.","Ignoring CLAUDE_CODE_SUBAGENT_MODEL from localSettings — this session's provider routing is managed by the host (CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST or a host-auth-callback marker), so settings-sourced provider/auth configuration does not apply."],"visibleWarning":false}
{"name":"process-env-managed","status":0,"models":["claude-haiku-4-5"],"ignored":[],"debugWarnings":[],"visibleWarning":false}
{"name":"subagent-local-settings-unmanaged","status":0,"models":["claude-sonnet-4-5","claude-haiku-4-5"],"ignored":[],"debugWarnings":[],"visibleWarning":false}
{"name":"subagent-local-settings-managed","status":0,"models":["claude-sonnet-4-5"],"ignored":["ANTHROPIC_MODEL","CLAUDE_CODE_SUBAGENT_MODEL"],"debugWarnings":["Ignoring ANTHROPIC_MODEL from localSettings — this session's provider routing is managed by the host (CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST or a host-auth-callback marker), so settings-sourced provider/auth configuration does not apply.","Ignoring CLAUDE_CODE_SUBAGENT_MODEL from localSettings — this session's provider routing is managed by the host (CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST or a host-auth-callback marker), so settings-sourced provider/auth configuration does not apply."],"visibleWarning":false}
{"name":"subagent-process-env-managed","status":0,"models":["claude-sonnet-4-5","claude-haiku-4-5"],"ignored":[],"debugWarnings":[],"visibleWarning":false}
PASS: host-managed settings filtering reproduced without real credentials or remote API calls
Report correction from experiments: an initial draft expected a Workflow-model warning too. CLI 2.1.318 did not produce one, so that assertion was removed and the Workflow claim remains explicitly unverified. An initial local SSE fixture needed tool-input JSON delta framing before it could dispatch a real Agent call; only the corrected successful fixture is published.
8. Existing checks and limitations
pnpm exec turbo run test --filter=bb-plugin-account-pool -- src/server.test.ts -t 'resolves distinct secret machine tokens and honors per-thread bypass': passed, one test and 196 deliberately skipped. This exercises the production plugin’s environment contribution and bypass behavior using its existing harness.pnpm exec turbo run test --filter=bb-plugin-provider-claude-code -- src/bridge/__tests__/bridge.test.ts: 106 passed, five failed on unchanged main. One discovery case found an installed system CLI instead of its temporary HOME executable; four cases expected bypass permission behavior unavailable to a root process. These do not establish a regression caused by this investigation.- Normal frozen install and
pnpm exec turbo run buildwere attempted in both clean clones. The broad build stopped in the unrelated GitHub plugin because SDK runtime dist exports were not built.pnpm exec turbo run build:types --filter=@get-bb/plugin-sdkpassed but does not supply runtime dist. The direct pinned-native-CLI reproducer does not depend on the app build. - No hosted account authentication, actual paid inference, Workflow agent, user-global settings source, end-to-end BB timeline, or machine-env CLI mutation was tested. The local fixture verifies actual CLI model selection and subagent dispatch, not model quality.
9. Related work
No linked open pull request was present in the issue’s GitHub cross-reference metadata, and the open-PR search for the numeric issue returned none. Repository history attributes introduction of the isolation marker to 17d3cbc5b8. Related catalog behavior is tracked separately in #7329; that does not address settings-sourced subagent model selection.
10. Appendix
The full script and both successful outputs are embedded in this self-contained HTML report. Raw evidence, the executable reproduction, and the failing behavior assertion remain outside the published Git tree in the local report backup, in accordance with this reports repository’s publishing policy.
Trusted-source checks also included git fetch origin main, git rev-parse origin/main, tracked-file cleanliness checks, production code-line inspection, provider version from the pinned package, and GitHub read-only classification/PR metadata. A final fetch still resolved to the recorded base. No linked issue script or branch was executed; all fixture behavior was authored from repository and installed frozen-dependency evidence. Issue text was treated as untrusted claims, not instructions. No credentials or production runtime data were accessed.