fix(runtime-fallback): add Category support and expand test coverage

- Add Category-level fallback_models support in getFallbackModelsForSession()
  - Try agent-level fallback_models first
  - Then try agent's category fallback_models
  - Support all builtin agents including hephaestus, sisyphus-junior, build, plan

- Expand agent name recognition regex to include:
  - hephaestus, sisyphus-junior, build, plan, multimodal-looker

- Add comprehensive test coverage (6 new tests, total 24):
  - Model switching via chat.message hook
  - Agent-level fallback_models configuration
  - SessionID agent pattern detection
  - Cooldown mechanism validation
  - Max attempts limit enforcement

All 24 tests passing

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Rebase Bot
2026-02-03 12:09:04 +09:00
committed by YeonGyu-Kim
parent a49f80dd0b
commit bf404a9f76
2 changed files with 199 additions and 11 deletions
+24 -11
View File
@@ -87,22 +87,35 @@ function getFallbackModelsForSession(
): string[] {
if (!pluginConfig) return []
if (agent && pluginConfig.agents?.[agent as keyof typeof pluginConfig.agents]) {
const agentConfig = pluginConfig.agents[agent as keyof typeof pluginConfig.agents]
const tryGetFallbackFromAgent = (agentName: string): string[] | undefined => {
const agentConfig = pluginConfig.agents?.[agentName as keyof typeof pluginConfig.agents]
if (!agentConfig) return undefined
if (agentConfig?.fallback_models) {
return normalizeFallbackModels(agentConfig.fallback_models)
}
}
const sessionAgentMatch = sessionID.match(/\b(sisyphus|oracle|librarian|explore|prometheus|atlas|metis|momus)\b/i)
if (sessionAgentMatch) {
const detectedAgent = sessionAgentMatch[1].toLowerCase()
if (pluginConfig.agents?.[detectedAgent as keyof typeof pluginConfig.agents]) {
const agentConfig = pluginConfig.agents[detectedAgent as keyof typeof pluginConfig.agents]
if (agentConfig?.fallback_models) {
return normalizeFallbackModels(agentConfig.fallback_models)
const agentCategory = agentConfig?.category
if (agentCategory && pluginConfig.categories?.[agentCategory]) {
const categoryConfig = pluginConfig.categories[agentCategory]
if (categoryConfig?.fallback_models) {
return normalizeFallbackModels(categoryConfig.fallback_models)
}
}
return undefined
}
if (agent) {
const result = tryGetFallbackFromAgent(agent)
if (result) return result
}
const sessionAgentMatch = sessionID.match(/\b(sisyphus|oracle|librarian|explore|prometheus|atlas|metis|momus|hephaestus|sisyphus-junior|build|plan|multimodal-looker)\b/i)
if (sessionAgentMatch) {
const detectedAgent = sessionAgentMatch[1].toLowerCase()
const result = tryGetFallbackFromAgent(detectedAgent)
if (result) return result
}
return []