Skip to content

feat(cli): add --strict-config flag to reject unknown config keys#671

Open
grandmaster451 wants to merge 1 commit into
MoonshotAI:mainfrom
grandmaster451:feat/strict-config
Open

feat(cli): add --strict-config flag to reject unknown config keys#671
grandmaster451 wants to merge 1 commit into
MoonshotAI:mainfrom
grandmaster451:feat/strict-config

Conversation

@grandmaster451

Copy link
Copy Markdown

Adds a --strict-config CLI option that propagates through the SDK and agent core so that config.toml is parsed with a strict Zod schema.

Unknown keys at the top level and inside stable nested sections (permission, services, loop_control, background, thinking) are rejected with a clear config.invalid error. Provider and model alias tables remain open for custom fields.

Changes

  • Parse KimiConfigStrictSchema when strictConfig is enabled.
  • Keep strictness sticky across config reloads (getKimiConfig, setKimiConfig, removeKimiProvider, provider manager reload).
  • Add CLI flag and forward it through createKimiHarness / KimiCore.
  • Add unit tests for CLI parsing and strict config validation.

Testing

  • pnpm vitest run packages/agent-core/test/config/configs.test.ts
  • pnpm vitest run apps/kimi-code/test/cli/options.test.ts
  • pnpm run typecheck in packages/agent-core, packages/node-sdk, and apps/kimi-code

Adds a `--strict-config` CLI option that propagates through the SDK and
agent core so that `config.toml` is parsed with a strict Zod schema.
Unknown keys at the top level and inside stable nested sections
(permission, services, loop_control, background, thinking) are rejected
with a clear config.invalid error. Provider and model alias tables remain
open for custom fields.

- Parse `KimiConfigStrictSchema` when `strictConfig` is enabled.
- Keep strictness sticky across config reloads (getKimiConfig, setKimiConfig,
  removeKimiProvider, provider manager reload).
- Add CLI flag and forward it through `createKimiHarness` / `KimiCore`.
- Add unit tests for CLI parsing and strict config validation.
@changeset-bot

changeset-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e58d9e1

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

@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: e58d9e179b

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

const transformed = transformTomlData(data);
transformed['raw'] = raw;

const schema = options.strict ? KimiConfigStrictSchema : KimiConfigSchema;

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 Reject unknown top-level tables in strict config

When --strict-config is used, this parses the already-transformed object, but transformTomlData drops any unrecognized top-level table because object-valued keys only get copied for known sections. As a result, a config like [typo]\nkey = "value" is silently accepted even though the flag is meant to reject unknown top-level keys; validate the raw top-level keys or carry unknown table sections through before applying the strict schema.

Useful? React with 👍 / 👎.

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