Skip to content

feat(kap-server): accept secondary_model in the config API - #2228

Merged
7Sageer merged 2 commits into
mainfrom
feat/kap-server-config-secondary-model
Jul 27, 2026
Merged

feat(kap-server): accept secondary_model in the config API#2228
7Sageer merged 2 commits into
mainfrom
feat/kap-server-config-secondary-model

Conversation

@7Sageer

@7Sageer 7Sageer commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — the problem is explained below.

Problem

The engine supports the documented [secondary_model] configuration section, which lets newly spawned subagents bind to a separately configured model instead of inheriting the main agent's model. However, the server's configuration API (POST /api/v1/config) validates request bodies against a strict whitelist that does not include secondary_model, so API clients (web UI, extensions, external integrations) silently drop the field and the only way to set it is editing config.toml by hand.

What changed

  • POST /api/v1/config now accepts secondary_model. The route's existing generic per-domain dispatch converts it to the secondaryModel config domain and routes it through the standard section validation and persistence, so [secondary_model] lands in config.toml and event.config.changed fires as for any other domain.
  • GET /api/v1/config now hides the internal synthesized __secondary__ derived entry from the models view (it appears in the effective config whenever the recipe carries patch fields), matching how GET /models already filters it out of pickers. It can never persist — the config overlay strips it from models writes.
  • Added route tests covering round-trip persistence of secondary_model and the __secondary__ filtering.

secondary_model request shape

For API callers: the field is a model pointer plus a patch.

  • model — id of an entry in the configured models; newly spawned subagents bind to it.
  • Every other field is a model override applied only to subagents, accepting the same fields as [models.*.overrides]: default_effort, off_effort, support_efforts, max_context_size, max_input_size, max_output_size, capabilities, display_name, reasoning_key, adaptive_thinking.
  • Identity/connection fields (provider, api_key, base_url, …) do not belong here — they are inherited from the pointed entry. With no patch fields, subagents bind the pointed entry directly.
{ "secondary_model": { "model": "k3", "default_effort": "high", "max_output_size": 8192 } }

Responses echo the resolved recipe in camelCase (e.g. defaultEffort). Field reference: config docs.

Known limitation (pre-existing, unchanged): the session secondary-model warning is computed once when the main agent is created, so updating the section mid-session does not refresh GET /sessions/{id}/warnings; spawn-time resolution remains the backstop.

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.

POST /api/v1/config now accepts secondary_model, persisted to the
[secondary_model] config section via the generic per-domain dispatch.
GET /config also hides the synthesized __secondary__ derived entry
from the models view, matching the GET /models listing.
@changeset-bot

changeset-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cacecbe

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/kimi-code 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

@pkg-pr-new

pkg-pr-new Bot commented Jul 27, 2026

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

commit: cacecbe

Signed-off-by: 7Sageer <sag77r@hotmail.com>
@7Sageer
7Sageer merged commit 3b01782 into main Jul 27, 2026
26 of 27 checks passed
@7Sageer
7Sageer deleted the feat/kap-server-config-secondary-model branch July 27, 2026 08:45
7Sageer added a commit that referenced this pull request Jul 27, 2026
…API (#2243)

The secondary-model feature is still experimental (gated by
KIMI_CODE_EXPERIMENTAL_SECONDARY_MODEL and ignored by the interactive
TUI), so the config API support merged in #2228 should not produce a
user-facing changelog entry yet.
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