Skip to content

fix: MiniMax CN authentication and connection test timeout - #396

Closed
Kathie-yu wants to merge 4 commits into
craft-ai-agents:mainfrom
Kathie-yu:fix/minimax-cn-auth
Closed

Kathie-yu wants to merge 4 commits into
craft-ai-agents:mainfrom
Kathie-yu:fix/minimax-cn-auth

Conversation

@Kathie-yu

@Kathie-yu Kathie-yu commented Mar 11, 2026 •

Copy link
Copy Markdown
image

Summary

Fix MiniMax CN (minimax-cn) authentication failure and connection test timeout in Pi API Key mode. This serves as a follow-up fix to the MiniMax split introduced in v0.7.3 (Issue #386), addressing underlying SDK routing and timeout issues.

Changes

  • Fix provider alias: Removed incorrect minimax-cn → minimax mapping in PI_AUTH_PROVIDER_ALIASES — Pi SDK treats them as separate providers with distinct endpoints (api.minimax.io vs api.minimaxi.com).
  • Hide MiniMax in Anthropic mode: Added PI_ONLY_PRESET_KEYS filter so MiniMax presets only appear in Pi API Key mode where they can actually authenticate.
  • Fix test timeout: Added lightweight direct HTTP test for Pi providers using the anthropic-messages API, bypassing the heavy subprocess startup that exceeded the 20s timeout limit.
  • Add display name: Added minimax-cn entry to PI_AUTH_PROVIDER_DISPLAY_NAMES.

Testing

  • Anthropic API Key mode: MiniMax presets no longer appear ✅
  • Pi API Key mode → MiniMax CN: connection test passes ✅
  • Pi API Key mode → MiniMax CN: chat works in session ✅
  • Type checking: all affected packages pass tsc --noEmit ✅

Copilot AI review requested due to automatic review settings March 11, 2026 13:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes MiniMax CN (minimax-cn) authentication failures and Pi connection test timeouts by correcting provider routing/aliasing and introducing a faster direct HTTP connection test for Anthropic-compatible Pi providers.

Changes:

  • Remove incorrect minimax-cn → minimax aliasing and add minimax-cn display name support.
  • Hide MiniMax presets in Anthropic API Key mode where Pi SDK-based authentication is required.
  • Add a lightweight Anthropic-compatible /v1/messages HTTP connection test path for Pi providers, falling back to the existing subprocess-based test when not applicable.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/shared/src/agent/backend/internal/drivers/pi.ts Adds direct HTTP connection test for anthropic-messages Pi providers to avoid subprocess startup timeouts.
packages/shared/src/agent/backend/internal/driver-types.ts Updates testConnection driver contract to allow “decline to handle” via null.
packages/shared/src/agent/backend/factory.ts Handles null driver results by falling through to the generic subprocess connection test.
packages/server-core/src/domain/connection-setup-logic.ts Adds display name mapping for minimax-cn.
apps/electron/src/renderer/components/apisetup/submit-helpers.ts Fixes Pi auth provider aliasing so minimax-cn passes through as its own provider key.
apps/electron/src/renderer/components/apisetup/ApiKeyInput.tsx Filters out MiniMax presets in Anthropic API Key mode; keeps them for Pi API Key flow.
Comments suppressed due to low confidence (1)

apps/electron/src/renderer/components/apisetup/submit-helpers.ts:27

  • resolvePiAuthProviderForSubmit behavior changed for MiniMax variants (only minimax-global is now aliased; minimax-cn should pass through). There are existing bun tests for this helper (ApiKeyInput.test.ts), but they don’t cover these MiniMax cases—please add assertions for minimax-global → minimax and minimax-cn → minimax-cn to prevent regressions.
export function resolvePiAuthProviderForSubmit(
  activePreset: PresetKey,
  lastNonCustomPreset: PresetKey | null
): string | undefined {
  if (activePreset === 'custom') {
    // Pi SDK needs a provider hint for auth header formatting even when
    // the URL is user-provided — default to anthropic as the safest baseline.
    const resolved = lastNonCustomPreset && lastNonCustomPreset !== 'custom'
      ? lastNonCustomPreset
      : 'anthropic'
    return PI_AUTH_PROVIDER_ALIASES[resolved] ?? resolved
  }

  return PI_AUTH_PROVIDER_ALIASES[activePreset] ?? activePreset
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread packages/shared/src/agent/backend/internal/drivers/pi.ts Outdated
Comment thread apps/electron/src/renderer/components/apisetup/submit-helpers.ts
Kathie-yu added a commit to Kathie-yu/craft-agents-oss that referenced this pull request Mar 11, 2026
args.model may arrive as 'pi/<id>' but Pi SDK model registry uses bare
IDs. Without stripping the prefix, find() always misses and falls back
to models[0], potentially using the wrong model's API type and baseUrl.

Addresses Copilot review comment on PR craft-ai-agents#396.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Kathie-yu and others added 2 commits March 12, 2026 15:10
Three issues fixed:

1. PI_AUTH_PROVIDER_ALIASES incorrectly mapped 'minimax-cn' → 'minimax',
   causing Pi SDK to use the Global endpoint (api.minimax.io) for CN keys,
   resulting in 401 authentication errors. Removed the alias so 'minimax-cn'
   maps 1:1 to the Pi SDK provider.

2. MiniMax presets (minimax-global/cn) were visible in Anthropic API Key mode
   where they can't work (wrong auth flow). Added PI_ONLY_PRESET_KEYS filter
   to hide them; they remain available in Pi API Key mode.

3. Pi test connection spawned a full subprocess + SDK initialization that
   exceeded the 20s timeout. Added a lightweight direct HTTP test path for
   providers using the anthropic-messages API (like MiniMax), bypassing the
   heavy subprocess startup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
args.model may arrive as 'pi/<id>' but Pi SDK model registry uses bare
IDs. Without stripping the prefix, find() always misses and falls back
to models[0], potentially using the wrong model's API type and baseUrl.

Addresses Copilot review comment on PR craft-ai-agents#396.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rjulius23

Copy link
Copy Markdown
Collaborator

Was my bad, sorey fixing it on main.

Kathie-yu and others added 2 commits March 12, 2026 16:30
MiniMax CN API (api.minimaxi.com) rejects model names with the
'MiniMax-' prefix (e.g. MiniMax-M2.5-highspeed → 500) but accepts
bare names (M2.5-highspeed → 200). Strip the prefix in the Pi driver
testConnection path when piAuthProvider is 'minimax-cn'.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…path

MiniMax CN API rejects prefixed model IDs (e.g. MiniMax-M2.5-highspeed
→ 500). Strip the prefix in resolvePiModel() when piAuthProvider is
'minimax-cn' so the Pi SDK sends bare model names to the CN endpoint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Kathie-yu
Kathie-yu force-pushed the fix/minimax-cn-auth branch from 029b157 to 6d45464 Compare March 12, 2026 08:43
@Kathie-yu

Copy link
Copy Markdown
Author

Hi @rjulius23, I've rebased onto v0.7.4, all fixes apply cleanly.

Heads up on a new issue I found: MiniMax CN API (api.minimaxi.com) rejects model IDs with the
MiniMax- prefix — e.g. MiniMax-M2.5-highspeed → 500, but M2.5-highspeed → 200. The Pi SDK
registry uses prefixed IDs, which work on Global but not CN.

I added a 3-line fix in two places (guarded by piAuthProvider === 'minimax-cn', zero impact on
other providers):

  • pi-agent-server/src/index.ts — strip prefix in resolvePiModel() for chat path
  • shared/.../drivers/pi.ts — strip prefix in testConnection() for connection test

Happy to close if you'd rather fix on main — just flagging since it needs a CN API key to
reproduce.

@rjulius23

Copy link
Copy Markdown
Collaborator

Yes sorry was an oversight from my side fixing the minimax-cn in todays release and introduce webhooks as well.

@Kathie-yu

Copy link
Copy Markdown
Author

Thanks for the heads up! Closing this PR then. Looking forward to the webhooks 🎉

@Kathie-yu Kathie-yu closed this Mar 12, 2026
@rjulius23 rjulius23 added the v0.7.5 Fixed in v0.7.5 label Mar 12, 2026
rjulius23 pushed a commit that referenced this pull request Mar 12, 2026
# v0.7.5 — Network Proxy, Webhooks & Community Fixes

---

## Features

- **Network proxy support** — configure HTTP/HTTPS proxies with bypass rules directly from App Settings. The proxy engine routes traffic through `undici` ProxyAgent instances, respects `NO_PROXY` rules, and configures both Node and Electron browser sessions. (46049d2, 0ed01c4, 81d1b1c, 0da3f26)
- **Webhook actions for automations** — automations can now fire HTTP webhooks with configurable auth, form payloads, response capture, replay, and persistent retry with exponential backoff. (993c75c, 588aab6)
- **Gemini 3.1 Flash Lite** — added to Google AI Studio preferred defaults. Thanks to [@naishyadav](https://github.com/naishyadav) for the suggestion in [#357](#357). (e36e9a2)
- **Dismiss working directory history items** — hover-visible X button on each recent directory entry to remove it from history. Thanks to [@jjjrmy](https://github.com/jjjrmy) ([#346](#346)) and [@jonzhan](https://github.com/jonzhan) ([#391](#391)) for requesting this. (3bd55d6)

## Improvements

- **History truncation** — consolidated all history field truncation to a single `HISTORY_FIELD_MAX_LENGTH` constant instead of scattered hardcoded limits (8689a1d)
- **Craft source docs** — added Collections section to guide with emphasis on the nested title + properties item format (0837afa)

## Bug Fixes

- **MiniMax CN authentication** — removed incorrect `minimax-cn → minimax` alias, added lightweight direct HTTP test for Pi providers, and stripped MiniMax-prefix for CN API compatibility. Thanks to [@Kathie-yu](https://github.com/Kathie-yu) ([#396](#396)) and [@RimuruW](https://github.com/RimuruW) ([#386](#386)) for reporting. Fixes [#396](#396). (612c0e7)
- **Inline code in messages** — text between inline badges (sources, skills, files) now renders through the Markdown component, restoring inline code, bold, italic, and links. Thanks to [@linusrogge](https://github.com/linusrogge) for reporting [#378](#378). Fixes [#378](#378). (e7f88a3)
- **Zod/JSON Schema passthrough** — default Zod object schemas to `.passthrough()` to match JSON Schema semantics where `additionalProperties` defaults to `true`. Also preserved `additionalProperties` in MCP proxy tool schema round-trip. Fixes tools with loosely-typed schemas silently losing fields. (cf4b6ac, 42c173c)
- **Self-signed TLS certificates** — accept self-signed certificates for the configured remote server origin, fixing `ERR_CERT_AUTHORITY_INVALID` on `wss://` connections (7148ebe)
- **File attachment in thin client mode** — paperclip button now uses browser-native `FileReader` API instead of server-side `fs.readFile()`, fixing silent failures when client and server filesystems differ (680cd19)
- **URL linkification** — strip trailing markdown characters (`**`, etc.) from linkified URLs that were producing broken links (24385e7, 65b8f35)
- **Automation action badges** — sidebar now shows correct "Prompt" / "Webhook" badges based on actual action types instead of hardcoding "Prompt" (dc42257)
- **Packaged server path fallback** — added `dist/resources` fallback for builds where `extraResources` output layout differs (edc5f61)
- **`$CRAFT_EVENT_DATA` missing labels** — all automation event payloads now include the session's current `labels` array, so webhooks and scripts can access label data. Fixes [#406](#406). (0f98f09)
- **Multi-select non-adjacent sessions** — Cmd-click now always toggles selection (standard OS behavior); opening in a new panel moves to Cmd-Shift-click. Fixes [#404](#404). (d4d7aff)
- **@ mention autocomplete with spaces** — spaces are now allowed in file mention queries (e.g. `@app availability.md`). The menu auto-closes Slack-style when a space produces no matches. Thanks to [@alexzadeh](https://github.com/alexzadeh) for reporting [#398](#398). Fixes [#398](#398). (1d06317)

---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v0.7.5 Fixed in v0.7.5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants