Skip to content

fix: gate always-thinking inference to OpenAI wires, plus catalog review follow-ups#2036

Merged
RealKai42 merged 3 commits into
mainfrom
kaiyi/catalog-review-fixes
Jul 22, 2026
Merged

fix: gate always-thinking inference to OpenAI wires, plus catalog review follow-ups#2036
RealKai42 merged 3 commits into
mainfrom
kaiyi/catalog-review-fixes

Conversation

@RealKai42

Copy link
Copy Markdown
Collaborator

Post-merge review follow-ups to #2015 and #2030, from a four-way deep review (catalog/kosong, v1 engine, v2 engine, tests & docs).

Blocker: alwaysThinking inference misfired on Claude/Gemini

The inference introduced in #2030 ("efforts present, no none, no toggle → always-thinking") is name-agnostic but wrong for the Anthropic/Google wires: Claude has a native off encoding (thinking: {type: 'disabled'}) that models.dev does not represent in efforts, so ~150 Claude-named models across anthropic/zenmux/opencode-shaped catalogs would have been marked always_thinking with no way to turn thinking off.

Fix: catalogProviderModels now strips the inferred marker when the model's final wire is not openai/openai_responses (per-model protocol overrides included). Verified against live models.dev data (168 providers):

  • anthropic (12), google (17), moonshotai (10): 0 models marked
  • openai: 23 models keep the marker (gpt-5-codex, o1, o3, …) — the intended population
  • Kimi models are unaffected on every path: k3 carries an explicit toggle, other Kimi entries declare no reasoning_options, so the inference never fired for them even before this fix

Deliberate trade-off: Claude served over openai-compatible gateways (e.g. github-copilot) keeps the marker — on that wire the only off encoding is reasoning_effort: 'none', which the catalog says the model rejects. Conservative direction (no Off offered) beats offering an option that errors upstream.

Other fixes

  • v1 provider-manager: kimi/google-genai/vertexai branches dropped a per-alias baseUrl (v2 already honored it for all wires)
  • thinking contract: rewrote the stale PHASE-6 header comment in v2 (clamp is unconditional; strict only governs effort validation), deleted three unreachable anthropic-thinking-cannot-disable warning branches, and normalized the requested effort value in v1 to match v2 (trim/lowercase, invalid values fall back to the model default)
  • tests: input-cap-preferred compaction triggers in both engines (no observed usage, context between cap and total window), kap-server WS status max_input_tokens assertion, v2 legacy status input-cap denominator
  • docs + changeset: max_input_size/off_effort/base_url field rows, catalog-refresh import behavior, zh wording, @moonshot-ai/kap-server changeset entry

Verification

  • kosong catalog 53, agent-core targeted 131, v2 fullCompaction+sessionLegacy 75, v2 kosong dir 273, kap-server broadcaster 51 — all green
  • tsc --noEmit clean on kosong / agent-core / agent-core-v2 / kap-server / node-sdk
  • oxlint --type-aware 0 errors on touched files (2 remaining warnings verified pre-existing on HEAD)
  • Live-data smoke against models.dev for the blocker fix (see above)

Out of scope (deliberately)

  • ~10 duplicated max_input_tokens ?? max_context_tokens sites across both engines deserve a shared helper — separate PR
  • Vendored anthropic-profile test fixtures have drifted from shipped logic — separate evaluation

…ow-ups

- catalog: strip the inferred alwaysThinking marker on non-OpenAI wires so
  Claude/Gemini keep their native off; verified against live models.dev
- v1 provider-manager: honor per-alias baseUrl on kimi/google-genai/vertexai
- thinking: rewrite the PHASE-6 contract comment, drop three dead
  cannot-disable warning branches, normalize requested effort in v1 to
  match v2
- tests: input-cap compaction preference in both engines, kap-server WS
  status cap, v2 legacy status input cap
- docs + changeset: new model fields, catalog-refresh behavior, kap-server
@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9712c04

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 changesets to release 6 packages
Name Type
@moonshot-ai/kosong Patch
@moonshot-ai/kimi-code-sdk Patch
@moonshot-ai/agent-core Patch
@moonshot-ai/agent-core-v2 Patch
@moonshot-ai/kap-server Patch
@moonshot-ai/kimi-code Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 22, 2026

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

commit: 9712c04

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

ℹ️ 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 thread packages/kosong/src/catalog.ts Outdated
The previous gate kept the marker only on the OpenAI wires, which wrongly
stripped it from Gemini 3 on the Google wires: its floor is
thinkingLevel MINIMAL with suppressed thoughts — still reasoning — so an
Off option there would be a lie. The criterion is now the wire's encoding,
not its family: strip only on anthropic and kimi, the two wires with a
protocol-level `thinking: {type: 'disabled'}` that the catalog's effort
list can never show. Verified against live models.dev data: google now
marks exactly the gemini-3 family (10), anthropic and moonshotai stay 0.

@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: 0d22acdee3

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

const protocol = model.protocol ?? providerWire;
if (
model.alwaysThinking === true &&
(protocol === 'anthropic' || protocol === 'kimi')

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 Keep Off available for non-Gemini-3 Google models

For Google/Vertex catalog models whose id is not gemini-3 but whose reasoning_options list has effort levels and no none/toggle, this condition leaves the inferred alwaysThinking marker in place because it only strips Anthropic/Kimi. That marker is persisted as always_thinking, and both engines clamp off back to a default effort, but the Google provider actually encodes off for non-Gemini-3 models as thinkingBudget: 0 (packages/kosong/src/providers/google-genai.ts), so those users lose a working Off setting. Please make the Google exception depend on the model family, keeping the marker only for Gemini 3 rather than the whole Google wire.

Useful? React with 👍 / 👎.

Comment thread packages/agent-core-v2/src/kosong/model/thinking.ts Outdated
…nking.ts file header

The scoped guide keeps comments in the top-of-file block only; the
function JSDoc shrinks to a short what-it-answers note matching its
neighbors. No behavior change.
@RealKai42
RealKai42 merged commit ba921ca into main Jul 22, 2026
23 of 24 checks passed
@RealKai42
RealKai42 deleted the kaiyi/catalog-review-fixes branch July 22, 2026 05:43
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