continue-custom/core/llm/toolSupport.test.ts
1bcMax becda53a17
feat: add ClawRouter as a provider for cost-optimized model routing (#11751)
* feat: add ClawRouter as a provider for cost-optimized model routing

ClawRouter is an open-source LLM router that automatically selects the
cheapest capable model for each request based on prompt complexity,
providing 78-96% cost savings on blended inference costs.

Changes:
- Add ClawRouterApi class extending OpenAI adapter
- Add 'clawrouter' provider to the type system
- Add ClawRouter models (auto, free, eco)
- Add ClawRouter provider config with UI setup
- Add ClawRouter logo
- Add documentation (clawrouter.mdx)

Closes #10843

* docs: enhance ClawRouter documentation

- Add ClawRouter to providers overview
- Expand documentation with:
  - Model capabilities configuration
  - Multiple roles setup
  - Troubleshooting section
  - Cost monitoring
  - Comparison with OpenRouter
  - Complexity dimensions explanation

* feat: add ClawRouter to core/llm/llms

- Add ClawRouter.ts extending OpenAI base class
- Register ClawRouter in llms/index.ts

* feat: add User-Agent headers for ClawRouter integration tracking

- Add 'User-Agent: Continue/IDE' header to identify Continue requests
- Add 'X-Continue-Provider: clawrouter' header for routing analytics
- Enhanced documentation with features list

This helps ClawRouter optimize routing decisions based on integration
source and enables better analytics for the Continue community.

* feat: complete ClawRouter integration with full provider support

- Add clawrouter to PROVIDER_HANDLES_TEMPLATING (autodetect.ts)
- Add clawrouter to PROVIDER_SUPPORTS_IMAGES (autodetect.ts)
- Add clawrouter tool support function (toolSupport.ts)
- Add supportsReasoningField and supportsReasoningDetailsField
- Add promptTemplates with osModelsEditPrompt
- Match OpenRouter implementation patterns

* feat: add ClawRouter to VS Code schema, docs nav, and AI SDK

- Add clawrouter to VS Code config_schema.json provider enum
- Add ClawRouter description in config_schema.json
- Add clawrouter to docs.json navigation (top-level providers)
- Add clawrouter to AI SDK PROVIDER_MAP

* docs: add wallet setup and x402 payment documentation

- Add Wallet & Payment Setup section to clawrouter.mdx
- Document payment tiers (free/eco/auto)
- Add wallet funding instructions (Solana/Base USDC)
- Add spend control configuration
- Update VS Code schema description with wallet info
- Update provider longDescription with payment options

* feat: add premium tier and enhanced ClawRouter features

- Add blockrun/premium routing profile (mission-critical tasks)
- Add dual-chain wallet support docs (Base EVM + Solana)
- Add model exclusion documentation
- Update routing profiles table with savings percentages
- Update comparison table with auth/payment differences
- Total 44+ models, 4 routing tiers

* test: add ClawRouter unit tests

- Add ClawRouter.vitest.ts (core/llm/llms)
  - Provider name verification
  - Default options validation
  - Reasoning field support
  - User-Agent header verification
  - Routing profiles acceptance

- Add ClawRouter.test.ts (openai-adapters)
  - Default apiBase
  - Custom apiBase override
  - Continue headers
  - OpenAI standard headers

- Add clawrouter tests to toolSupport.test.ts
  - blockrun/* routing profiles
  - Tool-supporting model patterns

* docs: add routing profile switching and enhanced error handling docs

- Add 'Switching Between Routing Profiles' section with full examples
- Add /model command tip for quick switching
- Add 'Error Handling' section comparing Continue vs ClawRouter
- Document automatic error recovery (429, 402, 500+, timeout)
- Add response header documentation for diagnostics
- Add AI-powered doctor command for troubleshooting

* fix: address PR review feedback - move docs to /more, resize logo, add provider constants, fix docs example

* fix: replace clawrouter logo with higher-res brand kit version (128x128)
2026-03-26 10:26:12 -07:00

599 lines
23 KiB
TypeScript

// core/llm/toolSupport.test.ts
import { PROVIDER_TOOL_SUPPORT, isRecommendedAgentModel } from "./toolSupport";
describe("PROVIDER_TOOL_SUPPORT", () => {
describe("continue-proxy", () => {
const supportsFn = PROVIDER_TOOL_SUPPORT["continue-proxy"];
it("should return true for Claude 3.5 models", () => {
expect(
supportsFn("ownerSlug/packageSlug/anthropic/claude-3-5-sonnet"),
).toBe(true);
expect(
supportsFn("ownerSlug/packageSlug/anthropic/claude-3.5-sonnet"),
).toBe(true);
});
it("should return true for Claude 3.7 models", () => {
expect(
supportsFn("ownerSlug/packageSlug/anthropic/claude-3-7-haiku"),
).toBe(true);
expect(
supportsFn("ownerSlug/packageSlug/anthropic/claude-3.7-sonnet"),
).toBe(true);
});
it("should return true for GPT-4 models", () => {
expect(supportsFn("ownerSlug/packageSlug/openai/gpt-4-turbo")).toBe(true);
expect(
supportsFn("ownerSlug/packageSlug/openai/gpt-4-1106-preview"),
).toBe(true);
});
it("should return true for Gemma models", () => {
expect(supportsFn("ownerSlug/packageSlug/openai/gemma")).toBe(true);
expect(supportsFn("ownerSlug/packageSlug/openai/gemma3")).toBe(true);
});
it("should return true for O3 models", () => {
expect(supportsFn("ownerSlug/packageSlug/openai/o3-preview")).toBe(true);
});
it("should return true for Gemini models", () => {
expect(supportsFn("ownerSlug/packageSlug/gemini/gemini-pro")).toBe(true);
expect(supportsFn("ownerSlug/packageSlug/gemini/gemini-2.5-pro")).toBe(
true,
);
});
it("should return false for unsupported models", () => {
expect(supportsFn("ownerSlug/packageSlug/openai/gpt-3.5-turbo")).toBe(
false,
);
expect(supportsFn("ownerSlug/packageSlug/anthropic/claude-2")).toBe(
false,
);
expect(supportsFn("ownerSlug/packageSlug/together/llama-3")).toBe(false);
});
it("should handle case insensitivity", () => {
expect(
supportsFn("ownerSlug/packageSlug/anthropic/CLAUDE-3-5-sonnet"),
).toBe(true);
expect(supportsFn("ownerSlug/packageSlug/openai/GPT-4-turbo")).toBe(true);
expect(supportsFn("ownerSlug/packageSlug/openai/Gemma3")).toBe(true);
expect(supportsFn("ownerSlug/packageSlug/gemini/GEMINI-pro")).toBe(true);
});
});
describe("anthropic", () => {
const supportsFn = PROVIDER_TOOL_SUPPORT["anthropic"];
it("should return true for Claude 3.5 models", () => {
expect(supportsFn("claude-3-5-sonnet")).toBe(true);
expect(supportsFn("claude-3.5-haiku")).toBe(true);
});
it("should return true for Claude 3.7 models", () => {
expect(supportsFn("claude-3-7-haiku")).toBe(true);
expect(supportsFn("claude-3.7-sonnet")).toBe(true);
});
it("should return undefined for unsupported models", () => {
expect(supportsFn("claude-2")).toBe(false);
expect(supportsFn("claude-instant")).toBe(false);
});
it("should handle case insensitivity", () => {
expect(supportsFn("CLAUDE-3-5-sonnet")).toBe(true);
expect(supportsFn("CLAUDE-3.7-haiku")).toBe(true);
});
});
describe("openai", () => {
const supportsFn = PROVIDER_TOOL_SUPPORT["openai"];
it("should return true for GPT-4 models", () => {
expect(supportsFn("gpt-4")).toBe(true);
expect(supportsFn("gpt-4-turbo")).toBe(true);
expect(supportsFn("gpt-4-1106-preview")).toBe(true);
});
it("should return true for O3 models", () => {
expect(supportsFn("o3")).toBe(true);
expect(supportsFn("o3-preview")).toBe(true);
});
it("should return true for Gemma models", () => {
expect(supportsFn("gemma")).toBe(true);
expect(supportsFn("gemma3")).toBe(true);
});
it("should return undefined for unsupported models", () => {
expect(supportsFn("gpt-3.5-turbo")).toBe(false);
expect(supportsFn("davinci")).toBe(false);
});
it("should handle case insensitivity", () => {
expect(supportsFn("GPT-4-turbo")).toBe(true);
expect(supportsFn("O3-preview")).toBe(true);
expect(supportsFn("Gemma3")).toBe(true);
});
});
describe("cohere", () => {
const supportsFn = PROVIDER_TOOL_SUPPORT["cohere"];
it("should return false for Command A Vision models", () => {
expect(supportsFn("command-a-vision")).toBe(false);
});
it("should return true for Command models", () => {
expect(supportsFn("command-r")).toBe(true);
expect(supportsFn("command-a")).toBe(true);
});
it("should return false for other models", () => {
expect(supportsFn("c4ai-aya-expanse-32b")).toBe(false);
});
});
describe("gemini", () => {
const supportsFn = PROVIDER_TOOL_SUPPORT["gemini"];
it("should return true for all Gemini models", () => {
expect(supportsFn("gemini-pro")).toBe(true);
expect(supportsFn("gemini-ultra")).toBe(true);
});
it("should return false for non-Gemini models", () => {
expect(supportsFn("gpt-4")).toBe(false);
expect(supportsFn("claude-3")).toBe(false);
});
it("should handle case insensitivity", () => {
expect(supportsFn("GEMINI-pro")).toBe(true);
expect(supportsFn("Gemini-2.5-Pro")).toBe(true);
});
});
describe("bedrock", () => {
const supportsFn = PROVIDER_TOOL_SUPPORT["bedrock"];
it("should return true for Claude 3.5 Sonnet models", () => {
expect(supportsFn("anthropic.claude-3-5-sonnet-20240620-v1:0")).toBe(
true,
);
expect(supportsFn("anthropic.claude-3.5-sonnet-20240620-v1:0")).toBe(
true,
);
});
it("should return true for Claude 3.7 Sonnet models", () => {
expect(supportsFn("anthropic.claude-3-7-sonnet-20240620-v1:0")).toBe(
true,
);
expect(supportsFn("anthropic.claude-3.7-sonnet-20240620-v1:0")).toBe(
true,
);
});
it("should return undefined for Claude Haiku and Opus models", () => {
expect(supportsFn("anthropic.claude-3-5-haiku-20240307-v1:0")).toBe(true);
expect(supportsFn("anthropic.claude-3.5-haiku-20240620-v1:0")).toBe(true);
expect(supportsFn("anthropic.claude-3-7-haiku-20240620-v1:0")).toBe(true);
expect(supportsFn("anthropic.claude-3-5-opus-20240620-v1:0")).toBe(true);
expect(supportsFn("anthropic.claude-3.7-opus-20240620-v1:0")).toBe(true);
});
it("should return undefined for other unsupported models", () => {
expect(supportsFn("anthropic.claude-instant-v1")).toBe(false);
expect(supportsFn("anthropic.titan-text-express-v1")).toBe(false);
});
it("should handle case insensitivity", () => {
expect(supportsFn("ANTHROPIC.CLAUDE-3-5-SONNET-20240620-v1:0")).toBe(
true,
);
expect(supportsFn("ANTHROPIC.CLAUDE-3.7-SONNET-20240620-v1:0")).toBe(
true,
);
});
});
describe("mistral", () => {
const supportsFn = PROVIDER_TOOL_SUPPORT["mistral"];
it("should return true for supported models", () => {
expect(supportsFn("mistral-large-latest")).toBe(true);
expect(supportsFn("mistral-small-latest")).toBe(true);
expect(supportsFn("codestral-latest")).toBe(true);
expect(supportsFn("ministral-8b-latest")).toBe(true);
expect(supportsFn("ministral-3b-latest")).toBe(true);
expect(supportsFn("pixtral-12b-2409")).toBe(true);
expect(supportsFn("pixtral-large-latest")).toBe(true);
expect(supportsFn("open-mistral-nemo")).toBe(true);
expect(supportsFn("devstral-latest")).toBe(true);
});
it("should return false for other unsupported models", () => {
expect(supportsFn("mistral-saba-latest")).toBe(false);
expect(supportsFn("mistral-embed")).toBe(false);
expect(supportsFn("mistral-moderation-latest")).toBe(false);
expect(supportsFn("mistral-ocr-latest")).toBe(false);
expect(supportsFn("open-codestral-mamba")).toBe(false);
});
it("should handle case insensitivity", () => {
expect(supportsFn("MISTRAL-LARGE-LATEST")).toBe(true);
expect(supportsFn("CODESTRAL-LATEST")).toBe(true);
expect(supportsFn("MINISTRAL-8B-LATEST")).toBe(true);
expect(supportsFn("PIXTRAL-12B-2409")).toBe(true);
expect(supportsFn("DEVSTRAL-LATEST")).toBe(true);
});
});
describe("ollama", () => {
const supportsFn = PROVIDER_TOOL_SUPPORT["ollama"];
it("should return true for supported models", () => {
expect(supportsFn("llama3.1")).toBe(true);
expect(supportsFn("llama3.2-8b")).toBe(true);
expect(supportsFn("llama3.3-70b")).toBe(true);
expect(supportsFn("qwen2")).toBe(true);
expect(supportsFn("mixtral-8x7b")).toBe(true);
expect(supportsFn("command-r")).toBe(true);
expect(supportsFn("command-a")).toBe(true);
expect(supportsFn("smollm2")).toBe(true);
expect(supportsFn("hermes3")).toBe(true);
expect(supportsFn("athene-v2")).toBe(true);
expect(supportsFn("nemotron-4-340b")).toBe(true);
expect(supportsFn("llama3-groq")).toBe(true);
expect(supportsFn("granite3")).toBe(true);
expect(supportsFn("aya-expanse")).toBe(true);
expect(supportsFn("firefunction-v2")).toBe(true);
expect(supportsFn("mistral-7b")).toBe(true);
expect(supportsFn("devstral-24b")).toBe(true);
});
it("should return false for explicitly unsupported models", () => {
expect(supportsFn("vision")).toBe(false);
expect(supportsFn("math")).toBe(false);
expect(supportsFn("guard")).toBe(false);
expect(supportsFn("mistrallite")).toBe(false);
expect(supportsFn("mistral-openorca")).toBe(false);
});
it("should return undefined for other models", () => {
expect(supportsFn("llama2")).toBe(false);
expect(supportsFn("phi-2")).toBe(false);
expect(supportsFn("falcon")).toBe(false);
});
it("should handle case insensitivity", () => {
expect(supportsFn("LLAMA3.1")).toBe(true);
expect(supportsFn("MIXTRAL-8x7b")).toBe(true);
expect(supportsFn("VISION")).toBe(false);
});
});
describe("lmstudio", () => {
const supportsFn = PROVIDER_TOOL_SUPPORT["lmstudio"];
it("should return true for supported models (same as ollama)", () => {
expect(supportsFn("llama3.1")).toBe(true);
expect(supportsFn("llama3.2-8b")).toBe(true);
expect(supportsFn("qwen2")).toBe(true);
expect(supportsFn("mixtral-8x7b")).toBe(true);
expect(supportsFn("mistral-7b")).toBe(true);
});
it("should return true for LM Studio hyphenated model IDs", () => {
// LM Studio uses hyphenated model identifiers like "Meta-Llama-3.1-8B-Instruct-GGUF"
expect(supportsFn("Meta-Llama-3.1-8B-Instruct-GGUF")).toBe(true);
expect(supportsFn("Meta-Llama-3.2-3B-Instruct")).toBe(true);
expect(supportsFn("Qwen2-7B-Instruct")).toBe(true);
expect(supportsFn("Mixtral-8x7B-Instruct-v0.1")).toBe(true);
expect(supportsFn("Mistral-7B-Instruct-v0.2")).toBe(true);
expect(supportsFn("llama-3.1-8b-instruct")).toBe(true);
});
it("should return false for explicitly unsupported models (same as ollama)", () => {
expect(supportsFn("vision")).toBe(false);
expect(supportsFn("math")).toBe(false);
expect(supportsFn("guard")).toBe(false);
expect(supportsFn("mistrallite")).toBe(false);
expect(supportsFn("mistral-openorca")).toBe(false);
});
it("should return false for mistral-openorca in all forms", () => {
// Hyphenated form (matches Ollama's exclusion directly)
expect(supportsFn("mistral-openorca")).toBe(false);
// Non-hyphenated form (must not bypass exclusion via "mistral" support match)
expect(supportsFn("MistralOpenOrca")).toBe(false);
// With suffix
expect(supportsFn("Mistral-OpenOrca-7B")).toBe(false);
});
it("should return false for hyphenated unsupported model names", () => {
expect(supportsFn("Llama-Vision-Free")).toBe(false);
expect(supportsFn("Math-Solver-7B")).toBe(false);
expect(supportsFn("Guard-Model")).toBe(false);
});
it("should return false for mistrallite in hyphenated forms", () => {
// Hyphenated form "mistral-lite" normalizes to "mistrallite" which must be excluded
expect(supportsFn("Mistral-Lite")).toBe(false);
expect(supportsFn("mistral-lite")).toBe(false);
});
it("should handle case insensitivity (same as ollama)", () => {
expect(supportsFn("LLAMA3.1")).toBe(true);
expect(supportsFn("MIXTRAL-8x7b")).toBe(true);
expect(supportsFn("VISION")).toBe(false);
});
it("should handle case insensitivity with hyphenated names", () => {
expect(supportsFn("META-LLAMA-3.1-8B-INSTRUCT")).toBe(true);
expect(supportsFn("Qwen2-7B-Instruct-GGUF")).toBe(true);
});
});
describe("xAI", () => {
const supportsFn = PROVIDER_TOOL_SUPPORT["xAI"];
it("should return true for Grok-3 models", () => {
expect(supportsFn("grok-3")).toBe(true);
expect(supportsFn("grok-3-mini")).toBe(true);
expect(supportsFn("grok-3-fast")).toBe(true);
});
it("should return true for Grok-4 models", () => {
expect(supportsFn("grok-4")).toBe(true);
expect(supportsFn("grok-4-fast-non-reasoning")).toBe(true);
expect(supportsFn("grok-4-fast-reasoning")).toBe(true);
expect(supportsFn("Grok-4-Fast")).toBe(true);
});
});
describe("novita", () => {
const supportsFn = PROVIDER_TOOL_SUPPORT["novita"];
it("should return true for exact match models", () => {
expect(supportsFn("deepseek/deepseek-r1-0528")).toBe(true);
expect(supportsFn("deepseek/deepseek-r1-turbo")).toBe(true);
expect(supportsFn("deepseek/deepseek-v3-0324")).toBe(true);
expect(supportsFn("deepseek/deepseek-v3-turbo")).toBe(true);
expect(supportsFn("meta-llama/llama-3.3-70b-instruct")).toBe(true);
expect(supportsFn("qwen/qwen-2.5-72b-instruct")).toBe(true);
expect(supportsFn("zai-org/glm-4.5")).toBe(true);
expect(supportsFn("moonshotai/kimi-k2-instruct")).toBe(true);
});
it("should return true for prefix match models", () => {
expect(supportsFn("qwen/qwen3-235b-a22b-instruct-2507")).toBe(true);
expect(supportsFn("openai/gpt-oss-20b")).toBe(true);
expect(supportsFn("openai/gpt-oss-120b")).toBe(true);
});
it("should return false for unsupported models", () => {
expect(supportsFn("deepseek/deepseek-chat")).toBe(false);
expect(supportsFn("meta-llama/llama-2-7b")).toBe(false);
expect(supportsFn("qwen/qwen-2.0-7b")).toBe(false);
expect(supportsFn("openai/gpt-4")).toBe(false);
});
});
describe("openrouter", () => {
const supportsFn = PROVIDER_TOOL_SUPPORT["openrouter"];
it("should return false for moonshotai/kimi-k2:free model", () => {
expect(supportsFn("moonshotai/kimi-k2:free")).toBe(false);
});
it("should return true for supported prefixes", () => {
expect(supportsFn("openai/gpt-4o")).toBe(true);
expect(supportsFn("anthropic/claude-sonnet-4")).toBe(true);
expect(supportsFn("google/gemini-2-flash")).toBe(true);
expect(supportsFn("google/gemini-3-pro-preview")).toBe(true);
expect(supportsFn("deepseek/deepseek-r1")).toBe(true);
expect(supportsFn("qwen/qwen3-coder-30b")).toBe(true);
expect(supportsFn("meta-llama/llama-4-scout")).toBe(true);
});
it("should strip :free/:extended/:beta suffixes before matching", () => {
expect(supportsFn("meta-llama/llama-3.2-3b-instruct:free")).toBe(true);
expect(supportsFn("deepseek/deepseek-r1:extended")).toBe(true);
expect(supportsFn("qwen/qwen3-coder:beta")).toBe(true);
});
it("should return false for unsupported models", () => {
expect(supportsFn("unknown/random-model")).toBe(false);
expect(supportsFn("some-provider/vision-model")).toBe(false);
});
it("should return false for excluded model patterns", () => {
expect(supportsFn("some/vision-model")).toBe(false);
expect(supportsFn("some/math-model")).toBe(false);
expect(supportsFn("some/guard-model")).toBe(false);
});
});
describe("clawrouter", () => {
const supportsFn = PROVIDER_TOOL_SUPPORT["clawrouter"];
it("should return true for blockrun routing profiles", () => {
expect(supportsFn("blockrun/auto")).toBe(true);
expect(supportsFn("blockrun/eco")).toBe(true);
expect(supportsFn("blockrun/premium")).toBe(true);
expect(supportsFn("blockrun/free")).toBe(true);
});
it("should return true for tool-supporting models", () => {
expect(supportsFn("gpt-4o")).toBe(true);
expect(supportsFn("claude-3-sonnet")).toBe(true);
expect(supportsFn("gemini-pro")).toBe(true);
expect(supportsFn("anthropic/claude-opus-4.6")).toBe(true);
});
it("should return false for non-tool-supporting patterns", () => {
expect(supportsFn("random-model")).toBe(false);
expect(supportsFn("")).toBe(false);
});
});
describe("edge cases", () => {
it("should handle empty model names", () => {
expect(PROVIDER_TOOL_SUPPORT["continue-proxy"]("")).toBe(false);
expect(PROVIDER_TOOL_SUPPORT["anthropic"]("")).toBe(false);
expect(PROVIDER_TOOL_SUPPORT["openai"]("")).toBe(false);
expect(PROVIDER_TOOL_SUPPORT["gemini"]("")).toBe(false);
expect(PROVIDER_TOOL_SUPPORT["bedrock"]("")).toBe(false);
expect(PROVIDER_TOOL_SUPPORT["ollama"]("")).toBe(false);
expect(PROVIDER_TOOL_SUPPORT["lmstudio"]("")).toBe(false);
expect(PROVIDER_TOOL_SUPPORT["novita"]("")).toBe(false);
});
it("should handle non-existent provider", () => {
// @ts-ignore - Testing runtime behavior with invalid provider
expect(PROVIDER_TOOL_SUPPORT["non-existent"]).toBe(undefined);
});
});
});
describe("isRecommendedAgentModel", () => {
describe("OpenAI models", () => {
it("should return true for o1, o3, o4 models", () => {
expect(isRecommendedAgentModel("o1")).toBe(true);
expect(isRecommendedAgentModel("o1-preview")).toBe(true);
expect(isRecommendedAgentModel("o3")).toBe(true);
expect(isRecommendedAgentModel("o3-mini")).toBe(true);
expect(isRecommendedAgentModel("o4")).toBe(true);
});
it("should return true for GPT-5 models", () => {
expect(isRecommendedAgentModel("gpt-5")).toBe(true);
expect(isRecommendedAgentModel("gpt-5-turbo")).toBe(true);
});
it("should return false for GPT-4 models", () => {
expect(isRecommendedAgentModel("gpt-4")).toBe(false);
expect(isRecommendedAgentModel("gpt-4-turbo")).toBe(false);
});
});
describe("DeepSeek models", () => {
it("should return true for DeepSeek R1/Reasoner models", () => {
expect(isRecommendedAgentModel("deepseek-r1")).toBe(true);
expect(isRecommendedAgentModel("deepseek-r1-0528")).toBe(true);
expect(isRecommendedAgentModel("deepseek-reasoner")).toBe(true);
});
it("should return false for non-reasoner DeepSeek models", () => {
expect(isRecommendedAgentModel("deepseek-chat")).toBe(false);
expect(isRecommendedAgentModel("deepseek-coder")).toBe(false);
});
});
describe("Gemini models", () => {
it("should return true for Gemini 2.5 Pro models", () => {
expect(isRecommendedAgentModel("gemini-2.5-pro")).toBe(true);
expect(isRecommendedAgentModel("gemini-2.5-pro-preview")).toBe(true);
});
it("should return true for Gemini 3.1 Pro and 3 Flash Preview models", () => {
expect(isRecommendedAgentModel("gemini-3.1-pro-preview")).toBe(true);
expect(isRecommendedAgentModel("gemini-3-flash-preview")).toBe(true);
});
it("should return false for Gemini Flash models", () => {
expect(isRecommendedAgentModel("gemini-2.5-flash")).toBe(false);
expect(isRecommendedAgentModel("gemini-3-flash")).toBe(false);
});
it("should return false for Gemini models without pro designation", () => {
expect(isRecommendedAgentModel("gemini-2.5")).toBe(false);
expect(isRecommendedAgentModel("gemini-3")).toBe(false);
});
it("should return false for older Gemini versions", () => {
expect(isRecommendedAgentModel("gemini-1.5-pro")).toBe(false);
expect(isRecommendedAgentModel("gemini-2.0-pro")).toBe(false);
});
});
describe("Claude models", () => {
it("should return true for Claude Sonnet 3.7 and later models", () => {
expect(isRecommendedAgentModel("claude-3-7-sonnet")).toBe(true);
expect(isRecommendedAgentModel("claude-3.7-sonnet")).toBe(true);
expect(isRecommendedAgentModel("claude-sonnet-4")).toBe(true);
expect(isRecommendedAgentModel("claude-4-sonnet")).toBe(true);
});
it("should return true for Claude Opus 4 models", () => {
expect(isRecommendedAgentModel("claude-opus-4")).toBe(true);
});
it("should return true for Claude 4-5 models", () => {
expect(isRecommendedAgentModel("claude-4-5")).toBe(true);
});
it("should return false for Claude 3.5 Sonnet models", () => {
expect(isRecommendedAgentModel("claude-3-5-sonnet")).toBe(false);
expect(isRecommendedAgentModel("claude-3.5-sonnet")).toBe(false);
});
it("should return false for Claude Haiku models", () => {
expect(isRecommendedAgentModel("claude-3-7-haiku")).toBe(false);
expect(isRecommendedAgentModel("claude-3.7-haiku")).toBe(false);
});
it("should return false for older Claude models", () => {
expect(isRecommendedAgentModel("claude-3-opus")).toBe(false);
expect(isRecommendedAgentModel("claude-2")).toBe(false);
});
});
describe("xAI models", () => {
it("should return true for Grok Code models", () => {
expect(isRecommendedAgentModel("grok-code")).toBe(true);
expect(isRecommendedAgentModel("grok-code-beta")).toBe(true);
});
it("should return false for non-code Grok models", () => {
expect(isRecommendedAgentModel("grok-3")).toBe(false);
expect(isRecommendedAgentModel("grok-4")).toBe(false);
});
});
describe("case insensitivity", () => {
it("should handle uppercase model names", () => {
expect(isRecommendedAgentModel("GEMINI-3.1-PRO-PREVIEW")).toBe(true);
expect(isRecommendedAgentModel("CLAUDE-4-SONNET")).toBe(true);
expect(isRecommendedAgentModel("DEEPSEEK-R1")).toBe(true);
expect(isRecommendedAgentModel("O3-MINI")).toBe(true);
});
it("should handle mixed case model names", () => {
expect(isRecommendedAgentModel("Gemini-3.1-Pro-Preview")).toBe(true);
expect(isRecommendedAgentModel("Claude-Opus-4")).toBe(true);
expect(isRecommendedAgentModel("DeepSeek-Reasoner")).toBe(true);
});
});
describe("edge cases", () => {
it("should return false for empty string", () => {
expect(isRecommendedAgentModel("")).toBe(false);
});
it("should return false for random strings", () => {
expect(isRecommendedAgentModel("random-model")).toBe(false);
expect(isRecommendedAgentModel("test")).toBe(false);
});
it("should return false for partial matches", () => {
expect(isRecommendedAgentModel("gemini-pro")).toBe(false);
expect(isRecommendedAgentModel("claude-sonnet")).toBe(false);
});
});
});