Skip to content

feat(kap-server): expose effective experimental flags in /meta - #2417

Open
liruifengv wants to merge 3 commits into
mainfrom
feat/kap-server-meta-experimental-flags
Open

feat(kap-server): expose effective experimental flags in /meta#2417
liruifengv wants to merge 3 commits into
mainfrom
feat/kap-server-meta-experimental-flags

Conversation

@liruifengv

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — this is the server half of the secondary-model settings UI (MoonshotAI/kimi-code-app#163); the problem is explained below.

Problem

Experimental flags resolve from several sources (master env, per-flag KIMI_CODE_EXPERIMENTAL_* env vars, the [experimental] config section, defaults), but HTTP clients can only see the persisted config section via GET /config. A UI therefore cannot tell whether a flag is actually in effect: with secondary-model enabled via env, the desktop/web settings UI would hide the secondary-model section while the feature is active — or, without any effective-state source, would have to bypass the experimental gate entirely.

What changed

GET /api/v1/meta now carries experimental_flags: the effective flag map (flag id → enabled) resolved per request from IFlagService.snapshot(), so it covers every flag source and flips live when the [experimental] config section is written — unlike the static persisted view in GET /config.

  • metaResponseSchema: optional experimental_flags record (older servers omit it; clients treat absence as "no flags enabled")
  • Meta route: static server-self fields stay frozen at registration; the flag map is computed per request through an injected getter
  • Route registration wires IFlagService.snapshot() from the Core scope

Tests (test/meta.test.ts) cover: default-off, env-enabled, live flip via POST /config, and env-outranks-config — with the developer-shell KIMI_CODE_EXPERIMENTAL_FLAG neutralized per test. Full kap-server suite passes (922 tests).

Changeset included: @moonshot-ai/kap-server minor.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update. (The field is self-documented in the OpenAPI schema via metaResponseSchema; no manual doc page covers /meta fields.)

@pkg-pr-new

pkg-pr-new Bot commented Jul 30, 2026

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

commit: fe9ea87

@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: 29399fa5c6

ℹ️ 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".

Comment thread packages/kap-server/src/routes/meta.ts Outdated
@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fe9ea87

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kap-server Patch

Not sure what this means? Click here to learn what changesets are.

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

@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the P2 startup-race comment in e04b1e4: the /meta handler now awaits IConfigService.ready before snapshotting flags (same edge-facade contract as the config route), plus a regression test asserting a persisted [experimental] flag is visible from the very first response. Full kap-server suite passes (923 tests).

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: e04b1e4daf

ℹ️ 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