Skip to content

feat(ai-gateway): add free LongCat 2.0 model - #5244

Merged
chrarnoldus merged 7 commits into
mainfrom
feat/longcat-free-model
Aug 13, 2026
Merged

feat(ai-gateway): add free LongCat 2.0 model#5244
chrarnoldus merged 7 commits into
mainfrom
feat/longcat-free-model

Conversation

@chrarnoldus

Copy link
Copy Markdown
Contributor

Summary

  • add the exclusive free meituan/longcat-2.0-free model backed by internal ID LongCat-2.0
  • route OpenAI-compatible chat completions to LongCat with binary, default-on Anthropic-style thinking
  • expose the requested context/output limits and focused catalog/provider coverage

Tests

  • not run locally; CI will handle validation as requested

Deployment

  • configure LONGCAT_API_KEY through the shared web environment workflow before enabling production traffic

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
@chrarnoldus chrarnoldus self-assigned this Aug 13, 2026
Comment thread apps/web/src/lib/ai-gateway/providers/longcat.ts
@kilo-code-bot

kilo-code-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The incremental change removes the disabled LongCat 2.0 model from unavailableModelIds, which remains safe because isDeadFreeModel and the non-public status still gate every routing path; the only open item is the previously flagged context_length value, which the author states is intentional per the supplied spec.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/ai-gateway/providers/longcat.ts 12 context_length: 1_048_756 is a transposition of the standard 1 MiB value 1_048_576 used by other 1M-context models; author replied the value is intentional per the supplied spec — flagged for final human confirmation
Files Reviewed (2 files, incremental)
  • apps/web/src/lib/ai-gateway/unavailable-models.ts - 0 issues
  • apps/web/src/lib/ai-gateway/unavailable-models.test.ts - 0 issues

Incremental review of commit ccc2a750: meituan/longcat-2.0-free was removed from unavailableModelIds (and its test assertion) while the model remains status: 'disabled' in longcat.ts. Verified this does not re-expose the model anywhere: the proxy route still rejects it via isDeadFreeModel (disabled + free) for both direct and auto-model requests (route.ts:666); the synced catalog excludes it because sync-providers.ts skips non-public kilo-exclusive models, so the /models/{provider}/{model}/endpoints route still 404s via missing stored metadata; enhancedModelList suppresses it via shouldSuppressOpenRouterModel; and free-endpoint-data-policy.ts skips non-public models. The removal also matches the AGENTS.md convention, which scopes unavailableModelIds to models removed from the codebase or region-restricted — a disabled-but-present model is already covered by dead-free gating. No memory-leak concerns: the change only deletes two static set entries/assertions with no timers, listeners, caches, or retained closures.

Fix these issues in Kilo Cloud

Previous Review Summaries (6 snapshots, latest commit 2d552b1)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 2d552b1)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The incremental change disables the LongCat 2.0 model (status: 'disabled' + unavailable-model list entry) consistently across routing, free-model detection, and tests; the only open item is the previously flagged context_length value, which the author states is intentional per the supplied spec.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/ai-gateway/providers/longcat.ts 12 context_length: 1_048_756 is a transposition of the standard 1 MiB value 1_048_576 used by other 1M-context models; author replied the value is intentional per the supplied spec — flagged for final human confirmation
Files Reviewed (4 files, incremental)
  • apps/web/src/lib/ai-gateway/providers/longcat.ts - 1 issue (pre-existing, carried forward)
  • apps/web/src/lib/ai-gateway/models.test.ts - 0 issues
  • apps/web/src/lib/ai-gateway/unavailable-models.ts - 0 issues
  • apps/web/src/lib/ai-gateway/unavailable-models.test.ts - 0 issues

Incremental review of commit 2d552b17: the model is now status: 'disabled' and its public ID is added to unavailableModelIds, matching the AGENTS.md unavailable-model convention. Verified the disablement is coherent end-to-end: findKiloExclusiveModel, isKiloExclusiveFreeModel, and preferredModels (conditional at models.ts:90) all exclude disabled models; isDeadFreeModel plus isUnavailableModel both gate the model in the proxy route, including auto-model requests; updated tests assert the disabled behavior and now lock in the disputed context_length value. No memory-leak concerns — the changes are static module-level constants and test assertions with no timers, listeners, caches, or retained closures.

Fix these issues in Kilo Cloud

Previous review (commit 093868e)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The incremental change is a description-string-only update in longcat.ts (no runtime or memory-leak concerns; no test asserts the description text). The previously flagged context_length (1_048_756 vs 1_048_576) remains unchanged — the author replied the value is intentional per the supplied model spec, so it stays flagged for final human confirmation.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/ai-gateway/providers/longcat.ts 12 context_length: 1_048_756 is a transposition of the standard 1 MiB value 1_048_576 used by every other 1M-context model in the repo; author replied the value is intentional per the supplied spec — flagged for final human confirmation
Files Reviewed (1 file, incremental)
  • apps/web/src/lib/ai-gateway/providers/longcat.ts - 1 issue (pre-existing, carried forward)

Incremental review of commit 093868e: the single changed line replaces the model description with "sparse mixture-of-experts ... 48B active parameters out of 1.6T total ... Available free in Kilo for a limited time." Verified: no test or source file asserts the old description text (grep across apps/web found no other reference), so the copy change cannot break tests or callers. The factual parameter counts cannot be independently verified from the repo; no code path depends on them. No memory-leak concerns — the change is a static string literal in a module-level constant, with no timers, listeners, caches, or retained closures introduced.

Fix these issues in Kilo Cloud

Previous review (commit b0e8af9)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The incremental test correction (effort: 'none' added to the disabled-reasoning case) is accurate and matches how isReasoningExplicitlyDisabled and model variants express disabled reasoning; the previously flagged context_length (1_048_756 vs 1_048_576) remains in longcat.ts — the PR author replied that the value is intentional per the supplied model spec, so this is left for human confirmation.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/ai-gateway/providers/longcat.ts 12 context_length: 1_048_756 is a transposition of the standard 1 MiB value 1_048_576 used by every other 1M-context model in the repo; author replied the value is intentional per the supplied spec — flagged for final human confirmation
Files Reviewed (1 file, incremental)
  • apps/web/src/lib/ai-gateway/providers/provider-definitions.test.ts - 0 issues

Incremental review of commit b0e8af9: the single changed line updates the LongCat disabled-reasoning test case from { enabled: false } to { enabled: false, effort: 'none' }. Verified against isReasoningExplicitlyDisabled in openrouter/request-helpers.ts: enabled: false alone does not mark reasoning disabled (the helper only returns true for effort === 'none', enable_thinking === false, or thinking.type === 'disabled'), so the old case would have asserted 'disabled' while the transform produced 'enabled'; adding effort: 'none' makes the expectation correct and mirrors the canonical disabled variant shape ({ enabled: false, effort: 'none' } in model-settings.ts). No memory-leak concerns (test-only change; no timers, listeners, or module-level mutable state).

Fix these issues in Kilo Cloud

Previous review (commit cd3dba5)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The incremental change broadening LongCat family detection is safe and consistent with existing matcher patterns; the previously flagged context_length (1_048_756 vs 1_048_576) remains in longcat.ts — the PR author replied that the value is intentional per the supplied model spec, so this is left for human confirmation.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/ai-gateway/providers/longcat.ts 12 context_length: 1_048_756 is a transposition of the standard 1 MiB value 1_048_576 used by every other 1M-context model in the repo; author replied the value is intentional per the supplied spec — flagged for final human confirmation
Files Reviewed (2 files, incremental)
  • apps/web/src/lib/ai-gateway/providers/longcat.ts - 1 issue (carried forward, author-disputed)
  • apps/web/src/lib/ai-gateway/providers/variants.test.ts - 0 issues

Incremental review of commit cd3dba5 ("fix(ai-gateway): broaden LongCat family detection"): isLongCatModel now uses requestedModel.includes('longcat'). Its only consumer is getFallbackModelVariants in variants.ts, where substring matchers (includes('gemma'), includes('laguna'), etc.) are the established pattern, and getAiSdkProvider routing remains an exact public_id match — so the broadening only affects fallback reasoning-variant selection, not provider routing. The updated test (vendor/longcat-preview) correctly pins the family-detection behavior. No memory-leak concerns (no timers, listeners, or module-level mutable state added).

Fix these issues in Kilo Cloud

Previous review (commit fc30770)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The incremental change correctly scopes LongCat getAiSdkProvider routing to the exact exclusive model ID; the previously flagged context_length (1_048_756 vs 1_048_576) remains in longcat.ts — the PR author replied that the value is intentional per the supplied model spec, so this is left for human confirmation.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/ai-gateway/providers/longcat.ts 12 context_length: 1_048_756 is a transposition of the standard 1 MiB value 1_048_576 used by every other 1M-context model in the repo; author replied the value is intentional per the supplied spec — flagged for final human confirmation
Files Reviewed (2 files, incremental)
  • apps/web/src/lib/ai-gateway/providers/model-settings.ts - 0 issues
  • apps/web/src/lib/ai-gateway/providers/longcat.ts - 1 issue (carried forward, author-disputed)

Incremental review of commit fc30770 ("fix(ai-gateway): scope LongCat client settings"): the change from the isLongCatModel prefix check to an exact model === longcat_2_free_model.public_id match is correct — the exclusive model catalog entry uses public_id as its id, so getGatewayOpenCodeSettings receives the exact string, and no other LongCat models exist that would lose the openai-compatible mapping. isLongCatModel remains used by variants.ts, so no dead code is introduced. No memory-leak concerns (no timers, listeners, or module-level mutable state added).

Fix these issues in Kilo Cloud

Previous review (commit b8949ef)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The new LongCat 2.0 exclusive model's advertised context_length (1_048_756) appears to be a transposition of the standard 1 MiB value 1_048_576, and the added test encodes the same value so CI cannot catch it.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/ai-gateway/providers/longcat.ts 12 context_length: 1_048_756 looks like a transposed 1_048_576 (2^20), the value used by every other 1M-context model in the repo; models.test.ts:98 asserts the same value, so the test locks in the error
Files Reviewed (12 files)
  • apps/web/src/lib/ai-gateway/providers/longcat.ts - 1 issue
  • apps/web/src/lib/ai-gateway/providers/provider-definitions.ts
  • apps/web/src/lib/ai-gateway/providers/provider-definitions.test.ts
  • apps/web/src/lib/ai-gateway/providers/types.ts
  • apps/web/src/lib/ai-gateway/providers/model-settings.ts
  • apps/web/src/lib/ai-gateway/providers/variants.ts
  • apps/web/src/lib/ai-gateway/providers/variants.test.ts
  • apps/web/src/lib/ai-gateway/providers/openrouter/inference-provider-id.ts
  • apps/web/src/lib/ai-gateway/models.ts
  • apps/web/src/lib/ai-gateway/models.test.ts
  • .env.local.example
  • ENVIRONMENT.md

Otherwise the integration is consistent with existing patterns: provider registration mirrors StreamLake/Martian (including env var plumbing via getEnvVariable and .env.local.example/ENVIRONMENT.md), routing resolves through the exclusive-model gateway field, getAiSdkProvider/getFallbackModelVariants hooks follow the family-prefix convention, and the thinking transform matches the Alibaba/Bytedance binary-reasoning approach. No memory-leak concerns introduced (no timers, listeners, or module-level mutable state beyond the existing provider-definition pattern).

Fix these issues in Kilo Cloud


Reviewed by kimi-k3 · Input: 127.9K · Output: 5.2K · Cached: 242.7K

Review guidance: REVIEW.md from base branch main

chrarnoldus and others added 6 commits August 13, 2026 09:14
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
@chrarnoldus
chrarnoldus merged commit dc5b2c5 into main Aug 13, 2026
15 checks passed
@chrarnoldus
chrarnoldus deleted the feat/longcat-free-model branch August 13, 2026 11:53
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