Skip to content

Proactively block free models when data collection is not allowed#4063

Merged
chrarnoldus merged 2 commits into
mainfrom
christiaan/deny-free
Jun 17, 2026
Merged

Proactively block free models when data collection is not allowed#4063
chrarnoldus merged 2 commits into
mainfrom
christiaan/deny-free

Conversation

@chrarnoldus

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread apps/web/src/lib/ai-gateway/models.test.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The previously flagged CRITICAL issue (test not awaiting async hasBestEffortGuessDataCollectionRequirement) is resolved. The function has been properly moved from models.ts to is-free-model.ts with correct imports and no circular dependencies.

Other Observations (not in diff)
File Line Issue
apps/web/src/app/api/openrouter/[...path]/route.ts 560 The effectiveProviderContext.experiment gate previously blocked all experiment routes when data collection is disallowed. The new check relies on hasBestEffortGuessDataCollectionRequirement which catches experiments via isFreeModelisPublicIdExperimented. If the Redis-backed membership set is unavailable or stale, experiment routes could slip through.
apps/web/src/app/api/openrouter/[...path]/route.ts 559 The detailed comment block explaining why experiment routes and models requiring data collection must be refused was removed. Consider restoring it for future maintainers.
Files Reviewed (4 files)
  • apps/web/src/app/api/openrouter/[...path]/route.ts - import path change only
  • apps/web/src/lib/ai-gateway/is-free-model.ts - newly added hasBestEffortGuessDataCollectionRequirement
  • apps/web/src/lib/ai-gateway/models.test.ts - fixed async await, restructured tests
  • apps/web/src/lib/ai-gateway/models.ts - removed stale isFreeModel import

Fix these issues in Kilo Cloud

Previous Review Summary (commit bbf96a2)

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

Previous review (commit bbf96a2)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The test for hasBestEffortGuessDataCollectionRequirement does not await the now-async function, causing the assertion to always compare a Promise against true and fail.

Overview

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

CRITICAL

File Line Issue
apps/web/src/lib/ai-gateway/models.test.ts 80 Test is not awaiting the async hasBestEffortGuessDataCollectionRequirement function — will always fail
Other Observations (not in diff)
File Line Issue
apps/web/src/app/api/openrouter/[...path]/route.ts 557 The PR removes the effectiveProviderContext.experiment gate that previously blocked all experiment routes when data collection is disallowed. The new check relies on hasBestEffortGuessDataCollectionRequirement which catches experiments via isFreeModelisPublicIdExperimented. If the Redis-backed membership set backing isPublicIdExperimented is unavailable or stale, experiment routes could slip through the data-collection-denied gate — which the PR title says it wants to "proactively block". Consider keeping the experiment property fallback or documenting the gap.
apps/web/src/app/api/openrouter/[...path]/route.ts 554 The detailed comment block explaining why experiment routes and models requiring data collection must be refused (R2 prompt capture, partner training evaluation, etc.) was removed without replacement. This context may be useful for future maintainers.
Files Reviewed (3 files)
  • apps/web/src/app/api/openrouter/[...path]/route.ts - 1 observation
  • apps/web/src/lib/ai-gateway/models.ts - no issues
  • apps/web/src/lib/ai-gateway/models.test.ts - 1 issue

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4-pro-20260423 · 235,564 tokens

Review guidance: REVIEW.md from base branch main

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
@chrarnoldus chrarnoldus merged commit 3f37765 into main Jun 17, 2026
16 checks passed
@chrarnoldus chrarnoldus deleted the christiaan/deny-free branch June 17, 2026 11:33
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