fix: tighten Anthropic provider matching and fix look-at test isolation
- Replace overly broad .includes('anthropic') with exact provider ID
matching against known Anthropic providers (anthropic, google-vertex-
anthropic, aws-bedrock-anthropic) in context-limit-resolver
- Add afterEach cleanup for vision-capable-models cache in look-at
tool tests to prevent cross-test state leakage
This commit is contained in:
@@ -8,7 +8,8 @@ export type ContextLimitModelCacheState = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isAnthropicProvider(providerID: string): boolean {
|
function isAnthropicProvider(providerID: string): boolean {
|
||||||
return providerID.toLowerCase().includes("anthropic")
|
const normalized = providerID.toLowerCase()
|
||||||
|
return normalized === "anthropic" || normalized === "google-vertex-anthropic" || normalized === "aws-bedrock-anthropic"
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAnthropicActualLimit(modelCacheState?: ContextLimitModelCacheState): number {
|
function getAnthropicActualLimit(modelCacheState?: ContextLimitModelCacheState): number {
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
import { describe, expect, test, mock } from "bun:test"
|
import { afterEach, describe, expect, test, mock } from "bun:test"
|
||||||
import type { ToolContext } from "@opencode-ai/plugin/tool"
|
import type { ToolContext } from "@opencode-ai/plugin/tool"
|
||||||
import { setVisionCapableModelsCache } from "../../shared/vision-capable-models-cache"
|
import { clearVisionCapableModelsCache, setVisionCapableModelsCache } from "../../shared/vision-capable-models-cache"
|
||||||
import { normalizeArgs, validateArgs, createLookAt } from "./tools"
|
import { normalizeArgs, validateArgs, createLookAt } from "./tools"
|
||||||
|
|
||||||
describe("look-at tool", () => {
|
describe("look-at tool", () => {
|
||||||
|
afterEach(() => {
|
||||||
|
clearVisionCapableModelsCache()
|
||||||
|
})
|
||||||
|
|
||||||
describe("normalizeArgs", () => {
|
describe("normalizeArgs", () => {
|
||||||
// given LLM might use `path` instead of `file_path`
|
// given LLM might use `path` instead of `file_path`
|
||||||
// when called with path parameter
|
// when called with path parameter
|
||||||
|
|||||||
Reference in New Issue
Block a user