Skip to content

Fix model collision by filtering and validating kimchi-dev provider models#121

Open
linkas45 wants to merge 5 commits intomasterfrom
fix/model-collision-kimchi-prefix
Open

Fix model collision by filtering and validating kimchi-dev provider models#121
linkas45 wants to merge 5 commits intomasterfrom
fix/model-collision-kimchi-prefix

Conversation

@linkas45
Copy link
Copy Markdown
Contributor

@linkas45 linkas45 commented May 1, 2026

Problem

When selecting models like , pi-mono's built-in model registry caused collisions due to duplicate model IDs under different providers:

  • provider →
  • provider →
  • provider →

This led to:

  1. Resolution of models to the wrong provider (e.g., )
  2. Attempt to load module which isn't bundled
  3. Runtime error:

Solution

Two-layer defense:

Layer 1: UI Filtering (ctrl+p cycling)

Only show models from provider in the model cycle list.

Layer 2: Runtime Validation

Added to throw a clear error if any non-kimchi model is selected, catching edge cases like saved sessions or CLI args.

Changes

  • : Exported constant
  • : Added filtering and validation
  • : Added 6 new tests (3 filtering + 3 validation)

Tests

All 724 tests pass, including 6 new tests for the fix.


Kimchi Summary

What changed

Filter the model registry to only display models from the kimchi-dev provider when cycling through available models with Ctrl+P. This prevents duplicate entries and API conflicts when model IDs collide with pi-mono's built-in providers.

Why

Model IDs such as claude-opus-4-7 exist under multiple providers (anthropic, amazon-bedrock) in pi-mono's registry, causing confusion and potential API routing conflicts. This ensures only Kimchi-served models are selectable.

Key changes

  • Added KIMCHI_PROVIDER constant ("kimchi-dev") in src/models.ts to centralize the provider identifier
  • Added validateKimchiModel() function in src/extensions/ui.ts that throws an error when attempting to use non-kimchi-dev models
  • Modified Ctrl+P model cycling logic in src/extensions/ui.ts to filter ctx.modelRegistry.getAvailable() by KIMCHI_PROVIDER
  • Added unit tests in src/extensions/ui.test.ts covering provider filtering and validation behavior

Impact

Users will now only see Kimchi-hosted models in the model switcher. Models from anthropic, amazon-bedrock, and other pi-mono built-in providers are excluded to avoid ID collisions.

@kimchi-review
Copy link
Copy Markdown

kimchi-review Bot commented May 1, 2026

Kimchi Code Review

Property Value
Commit c4d222b
Author @linkas45
Files changed 0
Review status Completed
Comments 0
Duration 26s

Summary

📊 Review Score: 92/100 (overall code quality — 0 lowest, 100 highest)
⏱️ Estimated effort to review: 2/5 (1 = trivial, 5 = very complex)

🧪 Tests: yes — Comprehensive test coverage added for the new model filtering logic and validateKimchiModel function. Tests cover edge cases including empty results, non-kimchi providers (anthropic, amazon-bedrock), and validation error messages.

No significant issues found. LGTM! 🎉

What to expect

Kimchi will analyze the changes in this pull request and post:

  • A summary of the overall changes
  • Inline comments on specific lines with findings categorized by issue type

The review typically completes within a few minutes. This comment will be updated once the review is ready.

Interact with Kimchi
  • @kimchi review — re-trigger a full review on the latest commit
  • @kimchi summary — regenerate the PR summary
  • @kimchi ignore — skip this PR (no review will be posted)
  • Reply to any inline comment to ask follow-up questions or request clarification
Configuration

Reviews are configured by your organization admin.
Review instructions, excluded directories, and severity thresholds can be adjusted per repository in the Kimchi dashboard.


Powered by Kimchi — AI-powered code review by CAST AI

Copy link
Copy Markdown

@kimchi-review kimchi-review Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Review Score: 88/100 (overall code quality — 0 lowest, 100 highest)
⏱️ Estimated effort to review: 2/5 (1 = trivial, 5 = very complex)

🧪 Tests: yes — Comprehensive tests added for model filtering logic (filtering by provider, empty results, all-kimchi scenarios) and validation behavior (accepting kimchi-dev models, rejecting others with specific error messages). However, tests duplicate implementation logic rather than importing the actual validation function.

📝 Found 2 issue(s). See inline comments for details.

Comment thread src/extensions/ui.ts Outdated
Comment thread src/extensions/ui.test.ts
@linkas45
Copy link
Copy Markdown
Contributor Author

linkas45 commented May 1, 2026

@kimchi review

@kimchi-review
Copy link
Copy Markdown

kimchi-review Bot commented May 1, 2026

🔄 Starting review on c4d222b
Triggered by @linkas45 via the command.

Copy link
Copy Markdown

@kimchi-review kimchi-review Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Review Score: 92/100 (overall code quality — 0 lowest, 100 highest)
⏱️ Estimated effort to review: 2/5 (1 = trivial, 5 = very complex)

🧪 Tests: yes — Comprehensive test coverage added for the new model filtering logic and validateKimchiModel function. Tests cover edge cases including empty results, non-kimchi providers (anthropic, amazon-bedrock), and validation error messages.

No significant issues found. LGTM! 🎉

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