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:
YeonGyu-Kim
2026-03-12 00:31:02 +09:00
parent 5ef391cb72
commit f1b5b1023f
2 changed files with 8 additions and 3 deletions
+2 -1
View File
@@ -8,7 +8,8 @@ export type ContextLimitModelCacheState = {
}
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 {
+6 -2
View File
@@ -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 { setVisionCapableModelsCache } from "../../shared/vision-capable-models-cache"
import { clearVisionCapableModelsCache, setVisionCapableModelsCache } from "../../shared/vision-capable-models-cache"
import { normalizeArgs, validateArgs, createLookAt } from "./tools"
describe("look-at tool", () => {
afterEach(() => {
clearVisionCapableModelsCache()
})
describe("normalizeArgs", () => {
// given LLM might use `path` instead of `file_path`
// when called with path parameter