Skip to content

fix(providers): accept moonshotai as alias for direct moonshot provider (#73876)#74162

Closed
hclsys wants to merge 1 commit into
openclaw:mainfrom
hclsys:fix-73876-moonshotai-provider-alias
Closed

fix(providers): accept moonshotai as alias for direct moonshot provider (#73876)#74162
hclsys wants to merge 1 commit into
openclaw:mainfrom
hclsys:fix-73876-moonshotai-provider-alias

Conversation

@hclsys

@hclsys hclsys commented Apr 29, 2026

Copy link
Copy Markdown

Fixes #73876.

Problem

`normalizeProviderId` in `src/agents/provider-id.ts` recognizes `moonshot` as the direct provider id. But model refs in the wild routinely arrive as `moonshotai/` (the form OpenRouter uses, and how Moonshot AI brands itself), so a config carrying `moonshotai/kimi-k2.6` fails to resolve to the direct Moonshot provider and surfaces `Unknown model`.

Fix

Add `moonshotai` and `moonshot-ai` to the alias table so they normalize to `moonshot`. Existing `moonshot/` configs, auth profiles, the plugin id, and docs are unchanged.

Tests

New `provider-id.test.ts` asserts:

  • `moonshotai` → `moonshot` (the new alias)
  • `moonshot-ai` → `moonshot` (the dashed alias variant)
  • `moonshot` → `moonshot` (regression — direct id still passes through)
  • `moonshotai/kimi-k2.6` → resolved provider `moonshot` (issue repro shape)
  • Unknown providers are still rejected
  • Casing is preserved on the model side

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Apr 29, 2026
@greptile-apps

greptile-apps Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds moonshotai and moonshot-ai as aliases for the direct moonshot provider in normalizeProviderId, so model refs like moonshotai/kimi-k2.6 (the form OpenRouter and Moonshot AI's own branding use) resolve correctly instead of surfacing Unknown model. The change follows the exact same alias-table pattern already used for qwen, zai, kimi, and other providers, and is covered by a new provider-id.test.ts with regression cases for the reported issue.

Confidence Score: 5/5

Safe to merge — the change is minimal, follows existing patterns, and is well-covered by tests.

Single targeted alias addition with no logic branching, no new dependencies, and comprehensive regression tests. No security surface, no data-path changes.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(providers): accept moonshotai as ali..." | Re-trigger Greptile

@clawsweeper

clawsweeper Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes:

This PR adds moonshotai and moonshot-ai aliases to provider-id normalization, adds focused provider-id regression tests, and records the Moonshot alias fix in the changelog.

Maintainer follow-up before merge:

This is already an open contributor implementation PR for a narrow valid bug; the remaining action is maintainer review, CI triage, and merge or requested revisions rather than an automated replacement PR.

Security review:

Security review cleared: The diff only changes provider-id normalization, a focused unit test, and a changelog entry; it introduces no security-sensitive or supply-chain surface.

Review details

Best possible solution:

Land this PR or an equivalent narrow main change that normalizes moonshotai and moonshot-ai to canonical moonshot, keeps plugin/auth/docs identifiers canonical as moonshot, preserves nested openrouter/moonshotai/... refs, and keeps the regression tests plus changelog entry so #73876 closes on merge.

Acceptance criteria:

  • pnpm test src/agents/provider-id.test.ts src/agents/model-selection.test.ts
  • pnpm check:changed

What I checked:

  • current_main_missing_aliases: normalizeProviderId() normalizes existing qwen/zai/opencode/kimi/bedrock/volcengine aliases and otherwise returns the lowercased input; there is no moonshotai or moonshot-ai branch on current main. (src/agents/provider-id.ts:3, fa467c20e327)
  • model_refs_route_through_normalizer: parseModelRef() splits on the first slash and normalizeModelRef() passes the provider segment through normalizeProviderId(), so moonshotai/kimi-k2.6 currently stays provider moonshotai while openrouter/moonshotai/... remains scoped to openrouter. (src/agents/model-selection-normalize.ts:65, fa467c20e327)
  • moonshot_provider_is_canonical_moonshot: The bundled Moonshot plugin id, provider list, provider request metadata, and model catalog are keyed as moonshot; moonshotai appears only as OpenRouter pricing metadata, not as a direct model-ref provider alias. (extensions/moonshot/openclaw.plugin.json:2, fa467c20e327)
  • docs_show_confusing_ref_shape: OpenRouter docs show openrouter/moonshotai/kimi-k2.6, while Moonshot docs use moonshot/kimi-k2.6, matching the linked report's copy/paste failure mode. Public docs: docs/providers/openrouter.md. (docs/providers/openrouter.md:50, fa467c20e327)
  • pr_diff_is_narrow: The latest public PR diff changes only CHANGELOG.md, adds src/agents/provider-id.test.ts, and adds the moonshotai/moonshot-ai alias branch in src/agents/provider-id.ts; it does not touch workflows, dependencies, lockfiles, scripts, package metadata, secret handling, generated artifacts, or vendored code. (src/agents/provider-id.ts:17, 8a68e09f6c51)
  • linked_bug_still_open: The linked bug report is still open with bug and regression labels and describes Unknown model: moonshotai/kimi-k2.6 on version 2026.4.26.

Likely related people:

  • steipete: Current main attributes the extracted provider-id normalizer and model-ref parsing files to Peter Steinberger, and upstream commit metadata links this handle to recent provider auth alias and Kimi canonicalization work in the same normalization path. (role: recent maintainer / introduced behavior; confidence: high; commits: 9ae7db556289, 9e4f478f866c, 37a7baf270eb; files: src/agents/provider-id.ts, src/agents/model-selection-normalize.ts)
  • vincentkoc: Commit metadata links this handle to OpenRouter compatibility alias work and provider auth metadata alignment, directly adjacent to the OpenRouter slug versus direct-provider normalization behavior. (role: adjacent owner; confidence: medium; commits: d13869aab94d, c0a7b6a51075; files: src/agents/model-selection-normalize.ts, docs/providers/openrouter.md, docs/providers/moonshot.md)
  • shakkernerd: Commit metadata links this handle to Moonshot manifest/catalog work; that catalog remains keyed as canonical moonshot, which is the target provider for the requested alias. (role: recent Moonshot plugin maintainer; confidence: medium; commits: 8749f1deb4bb, 00d2c3488932; files: extensions/moonshot/openclaw.plugin.json)

Remaining risk / open question:

  • Latest PR head 8a68e09f6c51085e25432642ac0fcca569ae1cba is not fully green: public check-runs report two failed checks and one in-progress parity gate, so maintainers need to inspect or rerun CI before merge.

Codex review notes: model gpt-5.5, reasoning high; reviewed against fa467c20e327.

@hclsys

This comment was marked as low quality.

@clawsweeper

clawsweeper Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes:

This PR adds moonshotai and moonshot-ai aliases to provider-id normalization, adds focused regression coverage, and records the Moonshot alias fix in the changelog.

Maintainer follow-up before merge:

This is an open contributor implementation PR with a narrow, apparently valid fix and low security surface; the remaining action is normal maintainer review, CI validation, and merge or requested revisions rather than an automated replacement PR.

Review details

Best possible solution:

Land this PR or an equivalent narrow main change that normalizes moonshotai and moonshot-ai to canonical moonshot, preserves canonical plugin/auth/docs IDs as moonshot, keeps nested openrouter/moonshotai/... refs intact, and includes regression coverage plus a changelog entry so the linked bug closes on merge.

Acceptance criteria:

  • pnpm test src/agents/provider-id.test.ts src/agents/model-selection.test.ts
  • pnpm check:changed

What I checked:

Likely related people:

  • steipete: Provider-id alias normalization and model-ref normalization are the central affected paths; prior ClawSweeper discussion for this PR attributes recent provider alias and normalization work in these files to this maintainer. (role: recent maintainer / introduced behavior; confidence: high; commits: 9e4f478f866c, 37a7baf270eb, c64f6adc83a5; files: src/agents/provider-id.ts, src/agents/model-selection-normalize.ts)
  • vincentkoc: Prior PR discussion links this maintainer to OpenRouter compatibility alias work and recent Moonshot/OpenRouter provider documentation, directly adjacent to the provider-slug mismatch. (role: adjacent owner; confidence: medium; commits: d13869aab94d, c0a7b6a51075; files: src/agents/model-selection-normalize.ts, docs/providers/moonshot.md, docs/providers/openrouter.md)
  • shakkernerd: Moonshot manifest and catalog ownership is relevant because the direct provider remains canonical moonshot while the requested behavior is an alias into that provider. (role: recent maintainer; confidence: medium; commits: 00d2c3488932, 8749f1deb4bb; files: extensions/moonshot/openclaw.plugin.json, docs/providers/moonshot.md)

Remaining risk / open question:

  • Targeted tests and the changed gate were not run in this read-only review; CI or maintainer validation still needs to prove the PR branch after merge/rebase.
  • Maintainers should confirm the dashed moonshot-ai spelling is desired as a public alias across model refs, auth lookup, and config lookup because normalizeProviderId() is shared beyond model selection.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 1390eadd9289.

…er (openclaw#73876)

OpenRouter's catalog and Moonshot AI's own branding both use the
`moonshotai` org slug (e.g. `moonshotai/kimi-k2.6` is what users see at
openrouter.ai). openclaw's direct Moonshot provider is registered as
`moonshot`, so users who copy the model ref from OpenRouter without the
`openrouter/` prefix hit `Unknown model: moonshotai/kimi-k2.6` despite
having a working direct Moonshot API key.

Add `moonshotai` and `moonshot-ai` to the `normalizeProviderId` alias
list so they resolve to the canonical `moonshot` provider id, matching
the existing alias pattern used for `qwencloud` → `qwen`,
`z.ai` → `zai`, `kimi-code` → `kimi`, etc.

Existing `moonshot/<model>` configs, auth profiles, plugin id (`moonshot`),
and docs are entirely unchanged. The fix is purely a normalization
expansion.

A new focused unit test (`src/agents/provider-id.test.ts`, the first
unit test specifically for `normalizeProviderId` /
`findNormalizedProviderValue`) covers:

- 14 cases including all existing aliases (qwen, zai, kimi, bedrock,
  volcengine) plus the new moonshotai/moonshot-ai mappings
- A regression for `findNormalizedProviderValue` matching alias keys
  against canonical config entries and vice versa

Sign-Off: hclsys
@hclsys

This comment was marked as low quality.

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

Labels

agents Agent runtime and tooling size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Direct provider names inconsistency (Eg. 'moonshot' should be 'moonshotai' to match OpenRouter slug convention)

1 participant