Skip to content

Shed inherited provider routing before spawning the local Claude subagent - #9907

Closed
lonexreb wants to merge 1 commit into
unslothai:mainfrom
lonexreb:fix/claude-subagent-provider-routing
Closed

lonexreb wants to merge 1 commit into
unslothai:mainfrom
lonexreb:fix/claude-subagent-provider-routing

Conversation

@lonexreb

Copy link
Copy Markdown
Contributor

What

Fixes #9864. With Claude Code configured for Azure AI Foundry (or Bedrock/Vertex) in the parent shell, the Unsloth local-agent bridge spawned a child that inherited those routing vars — and Claude Code's provider routing outranks ANTHROPIC_BASE_URL, so every unsloth_agent task went to the remote gateway instead of the local server, failing with a misleading unrecognized_model 404. Beyond the breakage, prompts the user intended to keep on-device left the machine.

How

_CLAUDE_ENV_UNSET grows the routing toggles (CLAUDE_CODE_USE_FOUNDRY / _BEDROCK / _VERTEX) plus the Foundry pair (ANTHROPIC_FOUNDRY_BASE_URL, ANTHROPIC_FOUNDRY_RESOURCE), exactly as the issue proposed. One list covers all three consumers: the MCP subagent bridge, unsloth start claude, and the printed --no-launch recipes (POSIX inline blanks and PowerShell Remove-Item lines alike). With the toggles unset the provider-specific *_BASE_URL companions for Bedrock/Vertex are inert, so those are left alone — the goal is restoring local routing, not scrubbing unrelated cloud config.

Reproduced → fixed

New test test_local_child_sheds_inherited_provider_routing sets the five vars in the parent env and asserts the child env carries none of them while ANTHROPIC_BASE_URL still points at the local server. It fails on main (the child inherits all five) and passes with this change. The WSL-bridge path blanks the same names to empty strings, the treatment the existing credential vars already get.

Tests

Full unsloth_cli/tests: 1053 passed, 7 skipped. Ruff clean, kwarg-spacing formatter applied.

@mahiatlinux
mahiatlinux self-requested a review August 28, 2026 05:09
@mahiatlinux mahiatlinux self-assigned this Aug 28, 2026
…gent

Claude Code's Foundry/Bedrock/Vertex routing outranks ANTHROPIC_BASE_URL,
so a parent shell configured for a corporate gateway silently sent every
local-agent task to that gateway, which 404s the local model id — and
prompts meant to stay on-device left the machine. _CLAUDE_ENV_UNSET now
strips the routing toggles (and the Foundry pair), covering the MCP
bridge, unsloth start claude, and the --no-launch recipes with one list.

Fixes unslothai#9864
@lonexreb
lonexreb force-pushed the fix/claude-subagent-provider-routing branch from 2cee9ca to 57ed954 Compare August 28, 2026 05:22
@mahiatlinux

Copy link
Copy Markdown
Contributor

Thanks for the contribution. #9871 now supersedes this PR. The focused provider-routing regression test from this branch is now in #9871, with your authorship preserved in commit d2cf858. The combined PR also covers the AWS, Google Cloud, and Mantle selectors. Closing this one so the fix continues in one place.

mahiatlinux pushed a commit that referenced this pull request Aug 28, 2026
)

Fixes #9864.

Pin Claude direct and MCP subagent sessions to the local Studio endpoint even when user settings or the inherited environment select Foundry, Bedrock, Vertex, AWS, Google Cloud, Mantle, or a Unix socket. Preserve compatibility with older Claude versions, WSL path translation, forwarded settings, subcommands, and concurrent sessions.

Includes focused inherited-provider regression coverage adapted from #9907 by @lonexreb.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants