Skip to content

fix(web): match MCP language models by provider and model#1230

Open
RitwijParmar wants to merge 1 commit into
sourcebot-dev:mainfrom
RitwijParmar:codex/sourcebot-mcp-language-model-identity
Open

fix(web): match MCP language models by provider and model#1230
RitwijParmar wants to merge 1 commit into
sourcebot-dev:mainfrom
RitwijParmar:codex/sourcebot-mcp-language-model-identity

Conversation

@RitwijParmar
Copy link
Copy Markdown

@RitwijParmar RitwijParmar commented May 26, 2026

Summary

  • Match MCP-requested language models by provider/model identity instead of the internal displayName-aware key
  • Keep displayName in the returned selected model info
  • Add a unit test covering displayName-less MCP model selection

Why

MCP clients can call ask_codebase with the externally documented provider/model fields. If the configured model has a displayName, comparing with getLanguageModelKey includes displayName and rejects an otherwise valid request.

Test

  • yarn workspace @sourcebot/web vitest src/features/chat/utils.test.ts --run

Summary by CodeRabbit

  • Refactor

    • Enhanced internal language model identification utilities for consistent and reliable model matching across features, improving how the system compares model configurations.
  • Tests

    • Added tests validating language model identity comparison behavior.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 03625162-b327-493a-be92-eab02bc742f9

📥 Commits

Reviewing files that changed from the base of the PR and between 96af7e8 and aa4fc01.

📒 Files selected for processing (3)
  • packages/web/src/features/chat/utils.test.ts
  • packages/web/src/features/chat/utils.ts
  • packages/web/src/features/mcp/askCodebase.ts

Walkthrough

This PR introduces a new utility isSameLanguageModelIdentity that compares language models by provider and model fields only, intentionally ignoring displayName. The utility is added to utils.ts with comprehensive test coverage, then integrated into askCodebase to replace key-based model matching.

Changes

Language Model Identity Comparison

Layer / File(s) Summary
isSameLanguageModelIdentity utility and tests
packages/web/src/features/chat/utils.ts, packages/web/src/features/chat/utils.test.ts
New exported function compares two LanguageModelInfo objects by provider and model only, intentionally excluding displayName. Test cases verify equivalence ignores displayName differences but detects model mismatches.
Integration into model matching
packages/web/src/features/mcp/askCodebase.ts
Import statement and model-selection predicate updated to use isSameLanguageModelIdentity instead of getLanguageModelKey for matching requested models against configured models.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(web): match MCP language models by provider and model' is fully related to the main change in the changeset, which adds logic to match MCP language models by provider and model identity instead of displayName-aware keys.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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