fix(delegate-task): reject primary agents in task subagent resolution

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-04-13 15:52:44 +09:00
parent f1cd4d73d6
commit 01a1b141e9
8 changed files with 224 additions and 115 deletions
@@ -0,0 +1,27 @@
import { findMostSpecificFallbackEntry } from "../../shared/fallback-chain-from-models"
import type { FallbackEntry } from "../../shared/model-requirements"
import type { DelegatedModelConfig } from "./types"
export function resolveEffectiveFallbackEntry(input: {
categoryModel: DelegatedModelConfig | undefined
configuredFallbackChain: FallbackEntry[] | undefined
resolution:
| { skipped: true }
| { fallbackEntry?: FallbackEntry; matchedFallback?: boolean }
| undefined
}): FallbackEntry | undefined {
const { categoryModel, configuredFallbackChain, resolution } = input
const resolutionSkipped = resolution && "skipped" in resolution
const resolvedFallbackEntry = resolution && !resolutionSkipped ? resolution.fallbackEntry : undefined
const matchedFallback = resolution && !resolutionSkipped ? resolution.matchedFallback === true : false
if (!matchedFallback || !categoryModel) {
return undefined
}
return resolvedFallbackEntry
?? (configuredFallbackChain
? findMostSpecificFallbackEntry(categoryModel.providerID, categoryModel.modelID, configuredFallbackChain)
: undefined)
}