Skip to content

fix(providers): fold developer role to system for moonshot - #7584

Merged
lidge-jun merged 1 commit into
devfrom
codex/moonshot-fold-developer-role
Oct 23, 2026
Merged

lidge-jun merged 1 commit into
devfrom
codex/moonshot-fold-developer-role

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes #7583.

api.moonshot.ai answers 400 Invalid request: role 'developer' is not allowed. The translated route already folds the role to system when nothing is recorded, but the native /v1/chat/completions passthrough only rewrites it on an explicit foldDeveloperRoleToSystem record, and the moonshot preset recorded nothing.

  • ProviderRegistryEntry gains foldDeveloperRoleToSystem, wired through the same paths as openaiChatEofTolerance: seed (providerConfigSeed, OAuth seed, fill-only backfill), static policy scalar, and routedProviderConfig resolve-time fill. A user value still wins, so an operator can set false explicitly.
  • moonshot records foldDeveloperRoleToSystem: true. Existing saved moonshot configs pick it up at resolve time without a re-add.

Verification

  • Reproduced on a live 2.89.0 proxy: native chat request to moonshot → 400 role 'developer' is not allowed (protocolTrace.mode: native, same-wire-native). After setting foldDeveloperRoleToSystem: true on the provider, a request with a developer message completes.
  • tsc --noEmit passes.
  • New tests/providers/moonshot-developer-role.test.ts (seed records the fold, pre-existing config is backfilled, explicit false wins, native passthrough rewrites developer → system) plus one assertion in provider-registry-parity.test.ts. Not run locally; left to CI.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Summary by CodeRabbit

  • New Features
    • Moonshot requests now convert developer-role messages to system-role messages, including chat completion passthrough.
    • This behavior is enabled by default for new and existing configurations without an explicit setting; an explicitly chosen value is preserved.

api.moonshot.ai rejects role 'developer' with a 400. The native
/v1/chat/completions passthrough only folds the role on an explicit
foldDeveloperRoleToSystem record, so let registry entries record it
(seeded and backfilled like openaiChatEofTolerance, user value wins)
and record true for moonshot.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner October 23, 2026 02:36
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T02:39:48.589163Z 733aa9f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the bug Something isn't working label Oct 23, 2026
@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between a9963bf and 733aa9f.

📒 Files selected for processing: 8
  • src/providers/derive.ts
  • src/providers/registry/entries-extended.ts
  • src/providers/registry/model-ids.ts
  • src/providers/registry/types.ts
  • src/providers/resolved-model-policy.ts
  • src/providers/routed-config.ts
  • tests/providers/moonshot-developer-role.test.ts
  • tests/providers/provider-registry-parity.test.ts
+----------------------------------------------------------------------------------+
| Crash early. A dead program normally does a lot less damage than a crippled one. |
+----------------------------------------------------------------------------------+
  \
   \     /)/)
        ( '')
        /  |
      o(___)
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lidge-jun
lidge-jun merged commit c51b0b4 into dev Oct 23, 2026
30 of 31 checks passed
@lidge-jun
lidge-jun deleted the codex/moonshot-fold-developer-role branch October 23, 2026 02:39

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 733aa9f9e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// api.moonshot.ai answers `400 Invalid request: role 'developer' is not allowed`. The
// translated route already folds when nothing is recorded, but the native
// /v1/chat/completions passthrough only folds on an explicit record, so record it here.
foldDeveloperRoleToSystem: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Scope folding to verified Moonshot endpoints

When a user selects the supported Custom base-URL option and points this preset at an OpenAI-compatible endpoint that accepts developer, this registry-wide value is still seeded and backfilled because the overridable moonshot row matches by provider name. Native Chat then silently rewrites the caller's developer messages to system, changing prompt semantics for a destination about which no compatibility fact was established. Apply this default only to the verified Moonshot endpoints, leaving arbitrary custom destinations unset unless the operator explicitly opts in.

Useful? React with 👍 / 👎.

// api.moonshot.ai answers `400 Invalid request: role 'developer' is not allowed`. The
// translated route already folds when nothing is recorded, but the native
// /v1/chat/completions passthrough only folds on an explicit record, so record it here.
foldDeveloperRoleToSystem: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Document the user-visible Moonshot default

This changes existing Moonshot native Chat requests from preserving developer to sending system, including through resolve-time backfill of saved configurations, but the commit contains no docs-site/ update describing the new preset default or the explicit false escape hatch. The scoped source instructions require documentation whenever configuration or user-visible behavior changes.

AGENTS.md reference: src/AGENTS.md:L29-L29

Useful? React with 👍 / 👎.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant