Skip to content

feat(kosong): add effortParam opt-in for anthropic output_config.effort - #2486

Open
kevingatera wants to merge 12 commits into
MoonshotAI:mainfrom
kevingatera:feat/kosong-effort-param
Open

feat(kosong): add effortParam opt-in for anthropic output_config.effort#2486
kevingatera wants to merge 12 commits into
MoonshotAI:mainfrom
kevingatera:feat/kosong-effort-param

Conversation

@kevingatera

Copy link
Copy Markdown

Related Issue

Resolve #2479

Problem

Some Anthropic-compatible providers require the output_config.effort wire field, but kimi-code never emits it unless the model is recognized as supporting it. Users routing such providers through the Anthropic transport have no way to opt in.

What changed

  • Add an effort_param opt-in (model config field and KIMI_MODEL_EFFORT_PARAM env var, mirroring adaptive_thinking / KIMI_MODEL_ADAPTIVE_THINKING) that, when enabled, makes the Anthropic provider emit output_config.effort.
  • Plumb the option through the managed-config merge and session provider wiring on the v1 engine, and mirror the full chain on the v2 engine (config schema, env overlay, catalog allowlist, provider options, thinking encoder) so the opt-in works on both engines.
  • Defaults to off, so behavior is unchanged unless explicitly enabled.
  • Tests cover the wire emission (with a negative control) and the env-var parsing; docs updated in both locales.

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.

kosong's anthropic adapter only emits output_config.effort for model names
it recognizes (opus-4-5 / adaptive). Third-party Anthropic-compatible
endpoints (e.g. z.ai GLM over /api/anthropic) honor effort on the enabled
thinking path but are not name-recognized, so /thinking levels silently no-op
there. Add a per-alias effortParam flag plumbed through the model alias
schema, provider-manager, and the oauth managed/merge types; when set, the
enabled-thinking path emits output_config.effort alongside budget_tokens.
…onfig.effort

The v2 engine silently accepted but dropped effortParam. Plumb it
through the same path as adaptiveThinking: the models config section
schema, KIMI_MODEL_EFFORT_PARAM in the env overlay, the catalog
provider-options allowlist, ProtocolProviderOptions, and the Anthropic
base, where the opt-in escapes the budget-path gate so
output_config.effort reaches the wire for non-name-recognized
Anthropic-compatible endpoints.
@changeset-bot

changeset-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0fc1f7a

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 Minor

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

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

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +147 to +151
/**
* Opt-in: declare that this model's endpoint honors Anthropic
* `output_config.effort` on the *enabled* thinking path. The provider only
* emits `output_config.effort` for model names it recognizes (adaptive
* profiles); third-party Anthropic-compatible endpoints that honor effort

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 Move the effortParam explanation into the module header

This property-level JSDoc introduces a non-header comment in agent-core-v2; move any necessary responsibility context into the top-of-file module header and let the interface name and type express the field itself. The scoped convention requires comments to live solely in that header rather than beside declarations.

AGENTS.md reference: packages/agent-core-v2/AGENTS.md:L17-L20

Useful? React with 👍 / 👎.

* this so `/thinking` effort levels take effect. budget_tokens is still
* sent (required by Anthropic's enabled-thinking contract; ignored by z.ai).
*/
effortParam?: boolean | undefined;

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 Remove explicit undefined from optional effortParam declarations

Declare this as effortParam?: boolean rather than redundantly adding | undefined, and make the same correction to the newly added declarations in packages/kosong/src/providers/anthropic.ts and packages/oauth/src/managed-kimi-code.ts. Optional properties already represent absence, and the repository explicitly prohibits the expanded form.

AGENTS.md reference: AGENTS.md:L55-L57

Useful? React with 👍 / 👎.

...(maxOutputSize !== undefined ? { maxOutputSize } : {}),
...(reasoningKey !== undefined ? { reasoningKey } : {}),
...(adaptiveThinking !== undefined ? { adaptiveThinking } : {}),
...(effortParam !== undefined ? { effortParam } : {}),

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 Pass effortParam directly instead of conditionally spreading it

Forward effortParam directly as an optional property instead of conditionally spreading a one-field object; the analogous new spread in provider-manager.ts should be changed as well. Directly passing undefined is the repository-required representation for absent optional values and avoids duplicating property-presence logic.

AGENTS.md reference: AGENTS.md:L52-L54

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.

Feature request: opt-in to emit Anthropic output_config.effort for providers that require it

1 participant