Skip to content

feat(agent-core-v2): fail fast on unsupported [secondary_model].default_effort - #3785

Merged
7Sageer merged 3 commits into
mainfrom
feat/subagent-default-effort-validation
Sep 15, 2026
Merged

7Sageer merged 3 commits into
mainfrom
feat/subagent-default-effort-validation

Conversation

@7Sageer

@7Sageer 7Sageer commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

Internal change, no linked issue — motivation explained below.

Problem

[secondary_model] offers subagents a pool of models, but the section-wide default_effort was a plain string checked against nothing:

  • At config load, assertValidSubagentModelConfig validated pool structure (aliases resolve, force constraints) but never the effort against any pool model's support_efforts.
  • At spawn, the section effort wins unconditionally as the subagent's explicit thinking level.
  • At request time the outcome depended on the provider: strict-thinking providers silently fell back to the model's default effort; non-strict providers sent the unsupported value on the wire for the server to reject or clamp.

Same config, two silent failure modes, no signal to the user. Effort scales are also model-private (low/high/max vs low/medium/high/xhigh/max/ultra), so one section-wide value is routinely meaningless for part of a heterogeneous pool.

What changed

assertValidSubagentModelConfig (runs at session scope creation, alongside the existing pool validation) now validates the section's default_effort:

  • The normalized effort must be acceptable by every bindable pool alias — and by the forced model under force = true — using the same modelSupportsThinkingEffort predicate as request-time validation, so config-time and request-time semantics agree.
  • off stays valid everywhere (pool-wide thinking kill switch); models declaring no support_efforts pass (nothing to check against, not a detectable silent failure).
  • Violations raise CONFIG_INVALID naming the effort, the offending model, and its supported efforts — session creation fails loudly instead of running with a silently different effort.

Per-entry effort defaults remain the model-level mechanism ([models."<alias>".overrides].default_effort); this change only removes the silent failure of the section-wide knob.

Tests: subagentModelsValidation.test.ts gains cases for the unsupported-effort failure (pool and force modes), the non-thinking-model failure, and the passing shapes (all models support the effort, no declared effort list, off).

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: the issue must have a maintainer's /approve).
  • 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.

@changeset-bot

changeset-bot Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 53a9b3d

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

@7Hanrui

7Hanrui commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@codex review

@pkg-pr-new

pkg-pr-new Bot commented Sep 15, 2026 •

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

commit: 53a9b3d

@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: 160f3c99cc

ℹ️ 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 pool = resolveSubagentModelPool(config);
if (pool !== undefined) assertValidSubagentModelPool(pool, modelCatalog);
assertValidSubagentDefaultEffort(section, pool, modelCatalog);

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 Add the required user-facing changeset

This changes CLI-visible behavior by rejecting previously accepted configuration during session creation, but the commit adds no .changeset entry, so the generated CLI changelog will omit the change. Add a patch changeset for @moonshot-ai/kimi-code.

AGENTS.md reference: AGENTS.md:L86-L87

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Deliberate decision: skipping the changeset. The new error only fires on configurations that were already broken in effect — the configured effort was silently ignored or clamped before this change, so no working setup changes behavior. The changelog entry would describe a failure mode no valid config can hit.

if (effort === undefined || pool === undefined) return;
for (const alias of Object.keys(pool.models)) {
const model = modelCatalog.get(alias);
if (modelSupportsThinkingEffort(effort, model, true)) continue;

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 off for always-thinking pool models

When a pool alias resolves to a model with alwaysThinking: true and default_effort = "off", modelSupportsThinkingEffort returns true for off unconditionally, so this validation accepts the configuration. During binding, resolveThinkingEffortForModel converts that explicit off to the model default or on, meaning session creation still succeeds while silently ignoring the configured pool-wide kill switch; handle always-thinking models before accepting off.

Useful? React with 👍 / 👎.

@7Hanrui

7Hanrui commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@codex review

@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: 484d78f6c7

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

);
}
if (modelSupportsThinkingEffort(effort, model, true)) continue;
if (!modelSupportsThinking(model)) {

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 Read adaptive thinking from provider options

When a custom-named Anthropic-compatible model relies on adaptive_thinking = true without also declaring the thinking capability, this rejects every concrete default_effort as unsupported. ModelCatalogService.buildProtocolProviderOptions stores that flag in model.providerOptions.adaptiveThinking, not on the top-level Model, while ProtocolAdapterRegistry.resolve later forwards it to the requester as valid thinking metadata; passing only model to modelSupportsThinking therefore produces a false negative and prevents session creation for an otherwise supported configuration. Include the provider-option adaptive flag in the metadata used by this validation.

Useful? React with 👍 / 👎.

@7Hanrui

7Hanrui commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 53a9b3dd4c

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

@7Sageer
7Sageer merged commit 513e71e into main Sep 15, 2026
15 checks passed
@7Sageer
7Sageer deleted the feat/subagent-default-effort-validation branch September 15, 2026 04:31
7723qqq added a commit to 7723qqq/kimi-code that referenced this pull request Sep 15, 2026
- MoonshotAI#3750 loop_control.compaction_max_attempts caps one compaction round's
  requests (default 5, upstream's, replacing the hardcoded 10)
- MoonshotAI#3785 reject an unsupported [secondary_model].default_effort at load
  time, and surface adaptive_thinking on the catalog model
- MoonshotAI#3681 warn on [models] entries missing the model field
- MoonshotAI#3752 tower resolves a caller by its last roster entry and retires
  duplicate agent ids; only ENOENT means an uninitialized workspace
- MoonshotAI#3778 evict completed subagent scopes behind an LRU cache
  (KIMI_CODE_SUBAGENT_SCOPE_CACHE_SIZE, default 32) and rebuild them from
  the persisted resume record on demand
- MoonshotAI#3747 aborting an unknown or already-settled prompt answers 40402
  instead of 40903, end to end through the protocol and kimi-web
- MoonshotAI#3720/MoonshotAI#3717 scope task notifications by session, so one session's print
  turn can no longer consume another's completion

The allowlist verdicts move to ported where the behavior landed, and
ROADMAP 6.1 records the evidence and what stayed open.
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.

2 participants