Skip to content

fix(agent-core-v2): fall back to a checked-in models.dev snapshot in source builds - #3042

Open
bj456736 wants to merge 1 commit into
MoonshotAI:mainfrom
bj456736:fix/built-in-catalog-source-fallback
Open

fix(agent-core-v2): fall back to a checked-in models.dev snapshot in source builds#3042
bj456736 wants to merge 1 commit into
MoonshotAI:mainfrom
bj456736:fix/built-in-catalog-source-fallback

Conversation

@bj456736

Copy link
Copy Markdown
Contributor

Problem

The built-in models.dev catalog fallback (#2110) is injected only through the __KIMI_CODE_BUILT_IN_CATALOG__ build-time define, which just the release / pkg-pr-new / native-build workflows populate (via KIMI_CODE_BUILT_IN_CATALOG_FILE). Any build bundling agent-core-v2 from source — notably the desktop app, which bundles @moonshot-ai/* sources directly with its own tsdown config — gets undefined for the snapshot. A failed models.dev fetch then surfaces as catalog_unavailable ("目录加载失败,请检查网络后重试") instead of using the built-in directory.

Fix

  • Check in a stripped snapshot at packages/agent-core-v2/src/app/kosongConfig/builtInModelsDev.snapshot.json (generated by apps/kimi-code/scripts/update-catalog.mjs; 191 providers) and read it with a ?raw import — the pattern this package already uses — as the default when the define is absent. Release builds still inject a fresh catalog through the define, which keeps priority.
  • Add pnpm --filter @moonshot-ai/agent-core-v2 catalog:update to regenerate the checked-in snapshot.
  • Add a builtInCatalog override to setModelsDevUpstreamForTest so the no-snapshot CATALOG_UNAVAILABLE path stays covered.

Downstream source bundlers (the desktop app) pick the fallback up automatically — no change needed there beyond bumping the submodule.

Tests

  • New: fetch failure falls back to the checked-in snapshot (entries listed, openai importable).
  • Existing catalog_unavailable test pinned to the no-snapshot path via the new hook.
  • 52/52 kosongConfig tests pass; typecheck / check-no-comments / import-boundaries / oxlint clean; verified the snapshot is inlined into the agent-core-v2 tsdown dist.

No changeset: not perceivable for CLI release users (they already ship the fresh define snapshot); the user-facing surface is the desktop app, which covers it on its side.

…source builds

The built-in catalog fallback was injected only through the
__KIMI_CODE_BUILT_IN_CATALOG__ define, which just the release workflows
populate. Any build bundling agent-core-v2 from source — the desktop app
bundles @moonshot-ai/* sources directly — got an undefined snapshot, so a
failed models.dev fetch surfaced as catalog_unavailable instead of using
the built-in directory.

Check in a stripped snapshot next to builtInModelsDev.ts (?raw import, the
pattern this package already uses) and prefer the define when present:
releases still ship a fresh catalog, source builds get the checked-in one.
Regenerate with pnpm --filter @moonshot-ai/agent-core-v2 catalog:update.
@changeset-bot

changeset-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d925421

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@bj456736

Copy link
Copy Markdown
Contributor Author

@codex review

@pkg-pr-new

pkg-pr-new Bot commented Aug 18, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@d925421
npx https://pkg.pr.new/@moonshot-ai/kimi-code@d925421

commit: d925421

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: d925421cc6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant