fix: honor agent variant overrides (#1394)
* fix(shared): honor agent variant overrides * test(shared): use model in fallback chain to verify override precedence Address PR review: test now uses claude-opus-4-5 (which has default variant 'max' in sisyphus chain) to properly verify that agent override 'high' takes precedence over the fallback chain's default variant.
This commit is contained in:
@@ -37,23 +37,26 @@ export function resolveVariantForModel(
|
||||
agentName: string,
|
||||
currentModel: { providerID: string; modelID: string },
|
||||
): string | undefined {
|
||||
const agentRequirement = AGENT_MODEL_REQUIREMENTS[agentName]
|
||||
if (agentRequirement) {
|
||||
return findVariantInChain(agentRequirement.fallbackChain, currentModel.providerID)
|
||||
}
|
||||
|
||||
const agentOverrides = config.agents as
|
||||
| Record<string, { category?: string }>
|
||||
| Record<string, { variant?: string; category?: string }>
|
||||
| undefined
|
||||
const agentOverride = agentOverrides
|
||||
? agentOverrides[agentName]
|
||||
?? Object.entries(agentOverrides).find(([key]) => key.toLowerCase() === agentName.toLowerCase())?.[1]
|
||||
: undefined
|
||||
if (agentOverride?.variant) {
|
||||
return agentOverride.variant
|
||||
}
|
||||
|
||||
const agentRequirement = AGENT_MODEL_REQUIREMENTS[agentName]
|
||||
if (agentRequirement) {
|
||||
return findVariantInChain(agentRequirement.fallbackChain, currentModel)
|
||||
}
|
||||
const categoryName = agentOverride?.category
|
||||
if (categoryName) {
|
||||
const categoryRequirement = CATEGORY_MODEL_REQUIREMENTS[categoryName]
|
||||
if (categoryRequirement) {
|
||||
return findVariantInChain(categoryRequirement.fallbackChain, currentModel.providerID)
|
||||
return findVariantInChain(categoryRequirement.fallbackChain, currentModel)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,10 +65,13 @@ export function resolveVariantForModel(
|
||||
|
||||
function findVariantInChain(
|
||||
fallbackChain: { providers: string[]; model: string; variant?: string }[],
|
||||
providerID: string,
|
||||
currentModel: { providerID: string; modelID: string },
|
||||
): string | undefined {
|
||||
for (const entry of fallbackChain) {
|
||||
if (entry.providers.includes(providerID)) {
|
||||
if (
|
||||
entry.providers.includes(currentModel.providerID)
|
||||
&& entry.model === currentModel.modelID
|
||||
) {
|
||||
return entry.variant
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user