fix(plugin): constrain Anthropic prefill guard

Tighten the assistant-tail repair after review so only the Anthropic provider is treated as prefill-rejecting, and so assistant-tail model metadata is evaluated independently from the last user model.

Add regression coverage for an allowed user model followed by a rejecting Anthropic assistant tail, plus a non-Anthropic provider carrying a Claude-looking model id.

Plan: plans/fix-anthropic-assistant-prefill-tail.md
This commit is contained in:
YeonGyu-Kim
2026-05-19 12:24:37 +09:00
parent 3509bf47ae
commit 45d670a7dc
2 changed files with 53 additions and 7 deletions
+4 -7
View File
@@ -5,11 +5,7 @@ import { normalizeModelID } from "../shared/model-normalization"
import type { CreatedHooks } from "../create-hooks"
const ASSISTANT_PREFILL_RECOVERY_TEXT = "[internal] Continue from the previous assistant state."
const ASSISTANT_PREFILL_UNSUPPORTED_PROVIDERS = new Set([
"anthropic",
"google-vertex-anthropic",
"opencode",
])
const ASSISTANT_PREFILL_UNSUPPORTED_PROVIDER = "anthropic"
const ASSISTANT_PREFILL_UNSUPPORTED_MODEL_PREFIXES = [
"claude-opus-4-7",
"claude-opus-4-6",
@@ -98,7 +94,7 @@ function shouldRepairAssistantPrefillForModel(model: ModelIdentifier | undefined
}
const providerID = model.providerID.toLowerCase()
if (!ASSISTANT_PREFILL_UNSUPPORTED_PROVIDERS.has(providerID)) {
if (providerID !== ASSISTANT_PREFILL_UNSUPPORTED_PROVIDER) {
return false
}
@@ -162,7 +158,8 @@ function ensureUserTurnAfterAssistantTail(output: MessagesTransformOutput): void
}
const shouldRepairAssistantTail = hasInternalContinuationTrigger(output.messages) ||
shouldRepairAssistantPrefillForModel(findLastUserModel(output.messages) ?? readModelIdentifier(lastMessage.info))
shouldRepairAssistantPrefillForModel(findLastUserModel(output.messages)) ||
shouldRepairAssistantPrefillForModel(readModelIdentifier(lastMessage.info))
if (!shouldRepairAssistantTail) {
return
}