From f1b5b1023f2b22de6a0b75a66abe0b6def25ca07 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Thu, 12 Mar 2026 00:31:02 +0900 Subject: [PATCH] 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 --- src/shared/context-limit-resolver.ts | 3 ++- src/tools/look-at/tools.test.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/shared/context-limit-resolver.ts b/src/shared/context-limit-resolver.ts index cb3c64e83..361fa45d0 100644 --- a/src/shared/context-limit-resolver.ts +++ b/src/shared/context-limit-resolver.ts @@ -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 { diff --git a/src/tools/look-at/tools.test.ts b/src/tools/look-at/tools.test.ts index 45a35f9a3..63713041b 100644 --- a/src/tools/look-at/tools.test.ts +++ b/src/tools/look-at/tools.test.ts @@ -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