HyunJun CHOI 58b7aff7bd fix: detect GPT models behind proxy providers (litellm, ollama) in isGptModel
isGptModel only matched openai/ and github-copilot/gpt- prefixes, causing
models like litellm/gpt-5.2 to fall into the Claude code path. This
injected Claude-specific thinking config, which the opencode runtime
translated into a reasoningSummary API parameter — rejected by OpenAI.

Extract model name after provider prefix and match against GPT model
name patterns (gpt-*, o1, o3, o4).

Closes #1788

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

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-13 11:38:00 +09:00

50 lines
1.2 KiB
TypeScript

/**
* Agent/model detection utilities for ultrawork message routing.
*
* Routing logic:
* 1. Planner agents (prometheus, plan) → planner.ts
* 2. GPT 5.2 models → gpt5.2.ts
* 3. Everything else (Claude, etc.) → default.ts
*/
import { isGptModel } from "../../../agents/types"
/**
* Checks if agent is a planner-type agent.
* Planners don't need ultrawork injection (they ARE the planner).
*/
export function isPlannerAgent(agentName?: string): boolean {
if (!agentName) return false
const lowerName = agentName.toLowerCase()
if (lowerName.includes("prometheus") || lowerName.includes("planner")) return true
const normalized = lowerName.replace(/[_-]+/g, " ")
return /\bplan\b/.test(normalized)
}
export { isGptModel }
/** Ultrawork message source type */
export type UltraworkSource = "planner" | "gpt" | "default"
/**
* Determines which ultrawork message source to use.
*/
export function getUltraworkSource(
agentName?: string,
modelID?: string
): UltraworkSource {
// Priority 1: Planner agents
if (isPlannerAgent(agentName)) {
return "planner"
}
// Priority 2: GPT models
if (modelID && isGptModel(modelID)) {
return "gpt"
}
// Default: Claude and other models
return "default"
}