Merge pull request #3328 from code-yeongyu/fix/effort-hook-small-model-3308

fix(anthropic-effort): skip effort injection for Haiku models
This commit is contained in:
YeonGyu-Kim
2026-04-11 13:48:50 +09:00
committed by GitHub
2 changed files with 31 additions and 0 deletions
+7
View File
@@ -1,6 +1,7 @@
import { log, normalizeModelID } from "../../shared"
const OPUS_PATTERN = /claude-.*opus/i
const EFFORT_UNSUPPORTED_PATTERN = /claude-.*haiku/i
const INTERNAL_SKIP_AGENTS = new Set(["title", "summary", "compaction"])
function isClaudeProvider(providerID: string, modelID: string): boolean {
@@ -14,6 +15,11 @@ function isOpusModel(modelID: string): boolean {
return OPUS_PATTERN.test(normalized)
}
function isEffortUnsupportedModel(modelID: string): boolean {
const normalized = normalizeModelID(modelID)
return EFFORT_UNSUPPORTED_PATTERN.test(normalized)
}
function shouldSkipForInternalAgent(agentName: string | undefined): boolean {
if (!agentName) return false
return INTERNAL_SKIP_AGENTS.has(agentName.trim().toLowerCase())
@@ -56,6 +62,7 @@ export function createAnthropicEffortHook() {
): Promise<void> => {
const { agent, model, message } = input
if (!model?.modelID || !model?.providerID) return
if (isEffortUnsupportedModel(model.modelID)) return
if (message.variant !== "max") return
if (!isClaudeProvider(model.providerID, model.modelID)) return
if (shouldSkipForInternalAgent(agent?.name)) return
+24
View File
@@ -147,6 +147,30 @@ describe("createAnthropicEffortHook", () => {
expect(output.options.effort).toBeUndefined()
})
describe("#given haiku models (effort unsupported)", () => {
const haikuModels = [
"claude-haiku-4-5",
"claude-haiku-4.6",
"claude-haiku",
"claude-haiku-20240307",
]
for (const modelID of haikuModels) {
it(`skips effort injection for ${modelID}`, async () => {
// given
const hook = createAnthropicEffortHook()
const { input, output } = createMockParams({ modelID })
// when
await hook["chat.params"](input, output)
// then
expect(output.options.effort).toBeUndefined()
expect(input.message.variant).toBe("max")
})
}
})
})
describe("existing options", () => {