Files
oh-my-opencode/src/hooks/shared/compaction-model-resolver.ts
T
YeonGyu-Kim 2d3d993eb6 fix(hooks/shared): replace as any with proper Record type cast
Cast pluginConfig.agents to Record type with proper structure

Remove eslint-disable comment for no-explicit-any

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

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-23 02:42:30 +09:00

35 lines
1.2 KiB
TypeScript

import type { OhMyOpenCodeConfig } from "../../config"
import { getSessionAgent } from "../../features/claude-code-session-state"
import { getAgentConfigKey } from "../../shared/agent-display-names"
export function resolveCompactionModel(
pluginConfig: OhMyOpenCodeConfig,
sessionID: string,
originalProviderID: string,
originalModelID: string
): { providerID: string; modelID: string } {
const sessionAgentName = getSessionAgent(sessionID)
if (!sessionAgentName || !pluginConfig.agents) {
return { providerID: originalProviderID, modelID: originalModelID }
}
const agentConfigKey = getAgentConfigKey(sessionAgentName)
const agentConfig = (pluginConfig.agents as Record<string, { compaction?: { model?: string } } | undefined>)[agentConfigKey]
const compactionConfig = agentConfig?.compaction
if (!compactionConfig?.model) {
return { providerID: originalProviderID, modelID: originalModelID }
}
const modelParts = compactionConfig.model.split("/")
if (modelParts.length < 2) {
return { providerID: originalProviderID, modelID: originalModelID }
}
return {
providerID: modelParts[0],
modelID: modelParts.slice(1).join("/"),
}
}