fix(workspace): project Anthropic adapter creds for BYOK MiniMax on claude-code (core#2709) #2711

Merged
devops-engineer merged 1 commits from fix/2709-claude-code-minimax-auth-projection into main 2026-06-13 06:05:40 +00:00
Member

Closes molecule-ai/molecule-core#2709.

After restart, a claude-code workspace using BYOK MiniMax only had MINIMAX_API_KEY set. The claude-code adapter uses the Anthropic SDK, which reads ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL, so it 401ed against api.minimax.io/anthropic.

Root cause: applyPlatformManagedLLMEnv returned early on the BYOK branch without projecting Anthropic-shaped credentials for the claude-code Anthropic SDK adapter.

Fix:

  • In the BYOK branch, when runtime is claude-code and the resolved provider declares an AuthTokenEnv, copy the first available provider auth-env value into AuthTokenEnv and project the provider's BaseURLAnthropic as ANTHROPIC_BASE_URL.
  • In the platform-managed Anthropic-native branch, use the provider's AuthTokenEnv instead of hardcoding ANTHROPIC_API_KEY (platform proxy keeps ANTHROPIC_API_KEY; MiniMax keeps ANTHROPIC_AUTH_TOKEN).

Test plan:

  • go test ./workspace-server/internal/handlers/ -run TestApplyPlatformManagedLLMEnv_ -v
  • Full package: go test ./workspace-server/internal/handlers/ (green).

Co-Authored-By: Claude noreply@anthropic.com

Closes molecule-ai/molecule-core#2709. After restart, a claude-code workspace using BYOK MiniMax only had `MINIMAX_API_KEY` set. The claude-code adapter uses the Anthropic SDK, which reads `ANTHROPIC_AUTH_TOKEN` and `ANTHROPIC_BASE_URL`, so it 401ed against `api.minimax.io/anthropic`. **Root cause:** `applyPlatformManagedLLMEnv` returned early on the BYOK branch without projecting Anthropic-shaped credentials for the claude-code Anthropic SDK adapter. **Fix:** - In the BYOK branch, when runtime is `claude-code` and the resolved provider declares an `AuthTokenEnv`, copy the first available provider auth-env value into `AuthTokenEnv` and project the provider's `BaseURLAnthropic` as `ANTHROPIC_BASE_URL`. - In the platform-managed Anthropic-native branch, use the provider's `AuthTokenEnv` instead of hardcoding `ANTHROPIC_API_KEY` (platform proxy keeps `ANTHROPIC_API_KEY`; MiniMax keeps `ANTHROPIC_AUTH_TOKEN`). **Test plan:** - `go test ./workspace-server/internal/handlers/ -run TestApplyPlatformManagedLLMEnv_ -v` - Full package: `go test ./workspace-server/internal/handlers/` (green). Co-Authored-By: Claude <noreply@anthropic.com>
agent-dev-a added 1 commit 2026-06-13 06:01:20 +00:00
fix(workspace): project Anthropic adapter creds for BYOK MiniMax on claude-code (core#2709)
Harness Replays / detect-changes (pull_request) Successful in 7s
Harness Replays / Harness Replays (pull_request) Successful in 2s
E2E Staging SaaS (full lifecycle) / pr-validate (pull_request) Has been cancelled
E2E Staging SaaS (full lifecycle) / E2E Staging SaaS (pull_request) Has been cancelled
E2E Staging SaaS (full lifecycle) / E2E Staging Platform Boot (pull_request) Has been cancelled
E2E Staging SaaS (full lifecycle) / E2E Staging Concierge user_tasks (pull_request) Has been cancelled
E2E Staging SaaS (full lifecycle) / E2E Staging Workspace Requests (core#2606) (pull_request) Has been cancelled
E2E Staging SaaS (full lifecycle) / E2E Staging Concierge Creates Workspace (pull_request) Has been cancelled
E2E Staging SaaS (full lifecycle) / E2E Staging Concierge (compile+skip) (pull_request) Has been cancelled
E2E Staging SaaS (full lifecycle) / E2E Staging Concierge Platform Agent (pull_request) Has been cancelled
CI / Python Lint & Test (pull_request) Successful in 4s
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 6s
Lint forbidden tenant-env keys / Scan for repo-host token write into tenant workspace surface (pull_request) Successful in 5s
sop-checklist / review-refire (pull_request_target) Has been skipped
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Successful in 6s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 7s
E2E Peer Visibility (literal MCP list_peers) / detect-changes (pull_request) Successful in 10s
reserved-path-review / reserved-path-review (pull_request_target) Successful in 7s
CI / Detect changes (pull_request) Successful in 15s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 11s
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, local-postgres-e2
E2E Peer Visibility (literal MCP list_peers) / E2E Peer Visibility (local) (pull_request) Has been skipped
sop-checklist / na-declarations (pull_request) N/A: (none)
E2E Chat / detect-changes (pull_request) Successful in 16s
sop-checklist / all-items-acked (pull_request_target) Successful in 9s
E2E Peer Visibility (literal MCP list_peers) / E2E Peer Visibility (pull_request) Successful in 5s
gate-check-v3 / gate-check (pull_request_target) Successful in 13s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 2s
E2E API Smoke Test / detect-changes (pull_request) Successful in 18s
CI / Platform (Go) (pull_request) Successful in 2s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 1s
CI / Canvas (Next.js) (pull_request) Successful in 2s
E2E Chat / E2E Chat (pull_request) Successful in 4s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2s
CI / Canvas Deploy Status (pull_request) Successful in 1s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 20s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 22s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 3s
CI / all-required (pull_request) Successful in 5s
Local Provision Lifecycle E2E / Local Provision Lifecycle E2E (stub) (pull_request) Successful in 26s
Local Provision Lifecycle E2E / Local Provision Lifecycle E2E (real image + MiniMax LLM, advisory) (pull_request) Successful in 24s
reserved-path-review / reserved-path-review (pull_request_review) Successful in 7s
qa-review / approved (pull_request_target) Review check failed via pull_request_review trigger
security-review / approved (pull_request_target) Review check failed via pull_request_review trigger
qa-review / approved (pull_request_review) Failing after 9s
security-review / approved (pull_request_review) Failing after 9s
audit-force-merge / audit (pull_request_target) Has been skipped
311b225bf6
After restart, a claude-code workspace using BYOK MiniMax only had
MINIMAX_API_KEY set. The claude-code adapter uses the Anthropic SDK, which
reads ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL, so it 401ed against
api.minimax.io/anthropic.

- In applyPlatformManagedLLMEnv's BYOK branch, when the runtime is claude-code
  and the resolved provider declares an AuthTokenEnv, copy the first available
  provider auth-env value into AuthTokenEnv and project the provider's
  BaseURLAnthropic as ANTHROPIC_BASE_URL.
- In the platform-managed Anthropic-native branch, use the provider's
  AuthTokenEnv instead of hardcoding ANTHROPIC_API_KEY (platform proxy keeps
  ANTHROPIC_API_KEY; MiniMax keeps ANTHROPIC_AUTH_TOKEN).
- Add regression test TestApplyPlatformManagedLLMEnv_BYOKMiniMaxProjectsAnthropicAdapterCreds.

Fixes #2709.

Co-Authored-By: Claude <noreply@anthropic.com>
agent-reviewer-cr2 approved these changes 2026-06-13 06:05:19 +00:00
agent-reviewer-cr2 left a comment
Member

APPROVED on head 311b225bf6. The BYOK early-return path now projects claude-code's Anthropic adapter credentials before returning: for a BYOK MiniMax workspace with MINIMAX_API_KEY, the resolved MiniMax provider is read from the provider registry, ANTHROPIC_AUTH_TOKEN is populated from the available provider auth env, and ANTHROPIC_BASE_URL is set to the MiniMax Anthropic-compatible endpoint. The original MINIMAX_API_KEY is preserved. Platform-managed claude-code projection also now uses the resolved provider's auth_token_env, which keeps platform on ANTHROPIC_API_KEY while allowing MiniMax-compatible providers to use ANTHROPIC_AUTH_TOKEN. Test coverage directly exercises the BYOK MiniMax claude-code projection and verifies token, base URL, resolved BYOK mode, and preserved MiniMax key. CI/all-required and the relevant Go/E2E checks are green; PR is mergeable.

APPROVED on head 311b225bf674e84b0d7f0c6d4a7b5a020d9b9a03. The BYOK early-return path now projects claude-code's Anthropic adapter credentials before returning: for a BYOK MiniMax workspace with `MINIMAX_API_KEY`, the resolved MiniMax provider is read from the provider registry, `ANTHROPIC_AUTH_TOKEN` is populated from the available provider auth env, and `ANTHROPIC_BASE_URL` is set to the MiniMax Anthropic-compatible endpoint. The original `MINIMAX_API_KEY` is preserved. Platform-managed claude-code projection also now uses the resolved provider's `auth_token_env`, which keeps platform on `ANTHROPIC_API_KEY` while allowing MiniMax-compatible providers to use `ANTHROPIC_AUTH_TOKEN`. Test coverage directly exercises the BYOK MiniMax claude-code projection and verifies token, base URL, resolved BYOK mode, and preserved MiniMax key. CI/all-required and the relevant Go/E2E checks are green; PR is mergeable.
Member

/sop-ack

/sop-ack
devops-engineer merged commit ab5dcee676 into main 2026-06-13 06:05:40 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#2711