Skip to content

fix: five correctness follow-ups to the catalog metadata work - #2030

Merged
RealKai42 merged 5 commits into
mainfrom
kaiyi/catalog-followups
Jul 21, 2026
Merged

fix: five correctness follow-ups to the catalog metadata work#2030
RealKai42 merged 5 commits into
mainfrom
kaiyi/catalog-followups

Conversation

@RealKai42

Copy link
Copy Markdown
Collaborator

Related Issue

Follow-up to #2015 (review comments from the automated review).

Problem

Five small correctness issues remained after the catalog metadata work:

  1. A configured thinking.effort = "OFF" (or with whitespace) was treated as a concrete effort and could be sent upstream as an invalid reasoning_effort — the clamp comparison was case-sensitive and the value was never normalized.
  2. A declared input cap could exceed the effective context window (e.g. catalog writes 272k, an override lowers the window to 128k), so compaction/overflow checks trusted a ceiling the model does not have.
  3. Context-usage percentages disagreed across status surfaces: session events and the session service used the input cap, while SDK getStatus and the v2 legacy status used the total window.
  4. A per-model override with a concrete endpoint but an unrecognized npm (e.g. @ai-sdk/xai) silently dropped the endpoint and routed the model to the provider default.
  5. The model inspector emitted resolved.maxInputSize / resolved.capabilities.max_input_tokens without provenance, breaking the per-value source contract.

What changed

  • Normalize the configured effort (trim + lowercase) on both engines before precedence and the always-on clamp.
  • Clamp maxInputSize to the effective maxContextSize in both effective-model resolvers.
  • Use max_input_tokens ?? max_context_tokens as the usage denominator (and reported cap) in the SDK getStatus and the v2 legacy status projection.
  • Fall back to the OpenAI-compatible wire for unrecognized override SDKs, preserving concrete endpoints (same fallback as top-level entries).
  • Attribute the input-limit fields in the model inspector (config / override / clamp / none).

Each fix carries targeted tests; full suites pass on kosong, node-sdk, agent-core, agent-core-v2, and the CLI, plus typecheck and full-repo oxlint.

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.

- Normalize a configured effort value (case/whitespace) before thinking
  resolution on both engines, so "OFF" is read as off instead of being
  sent upstream as an invalid effort.
- Clamp a declared input cap to the effective context window in the
  effective model resolution, so an override lowering max_context_size
  cannot leave a stale larger cap behind.
- Report context usage against the same effective cap
  (max_input_tokens ?? max_context_tokens) in the SDK getStatus and the
  v2 legacy status projections, matching the session-event and service
  surfaces.
- Preserve concretely declared per-model endpoints when the override
  npm is unrecognized, via the same OpenAI-compatible fallback used for
  top-level entries.
- Attribute resolved.maxInputSize and resolved.capabilities
  .max_input_tokens in the model inspector to their config, override,
  or clamp provenance.
@changeset-bot

changeset-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7c3d774

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 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/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 21, 2026

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

commit: 7c3d774

@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: 1dfad4ceda

ℹ️ 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/agent-core-v2/src/kosong/model/modelAuth.ts Outdated
Comment thread packages/agent-core/src/config/model.ts Outdated
Comment thread packages/agent-core-v2/src/kosong/model/inspection.ts Outdated
Comment thread packages/agent-core-v2/src/kosong/model/inspection.ts Outdated
Comment thread packages/kosong/src/catalog.ts Outdated
…status

- The overflow-learned provider window is now written into both
  max_context_tokens and max_input_tokens of the effective compaction
  context, so the strategy cannot bypass it by re-selecting the raw
  catalog input cap during overflow recovery.
- agent.status.updated publishes max_input_tokens ?? max_context_tokens,
  matching the other v1/v2 status surfaces.

@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: 82ffdaf386

ℹ️ 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/agent-core-v2/src/agent/profile/profileService.ts
Comment thread packages/agent-core-v2/test/agent/fullCompaction/fullCompaction.test.ts Outdated
…etary override SDKs

- effectiveModelAlias / effectiveModelConfig now build a copy before
  clamping maxInputSize to the effective window instead of rewriting
  the caller's config record in place.
- context_usage is clamped to 1 in the v2 legacy status, the v1
  session service, and the SDK getStatus; the default-model status
  fallback also resolves the input cap.
- Overrides naming known proprietary SDKs (Bedrock, Cohere) are
  refused before the OpenAI-compatible fallback, matching top-level
  import behavior.
- The inspector attributes a clamped maxInputSize to the clamp even
  when the raw value came from models.*.overrides.

@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: 8faae90434

ℹ️ 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/agent-core-v2/test/kosong/model/catalog.test.ts Outdated
Comment thread packages/agent-core-v2/src/kosong/model/inspection.ts
…w event ratio

- Whitespace-only configured efforts now read as absent, and the
  KIMI_MODEL_THINKING_EFFORT override is lowercased on both engines.
- kap-server's WS legacy status publishes max_input_tokens ??
  max_context_tokens like the other status surfaces.
- SDK getStatus keeps the ratio unclamped on purpose (>100% is the
  documented overflow signal on that path); schema-bounded REST status
  stays clamped to 1.
- Pin the provider-observed window beating a declared input cap with a
  v1 full-compaction regression test.
@RealKai42
RealKai42 merged commit ec88d35 into main Jul 21, 2026
23 of 24 checks passed
@RealKai42
RealKai42 deleted the kaiyi/catalog-followups branch July 21, 2026 19:13
@github-actions github-actions Bot mentioned this pull request Jul 21, 2026
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