feat: auto-detect model provider and apply appropriate options (#146)

When overriding an agent's model to a different provider, the agent
now automatically gets provider-appropriate reasoning options:

- GPT models: `reasoningEffort`, `textVerbosity`
- Anthropic models: `thinking` with `budgetTokens`

## Why utils.ts changes are required

The original flow merges overrides onto pre-built agent configs:

    mergeAgentConfig(sisyphusAgent, { model: "gpt-5.2" })
    // Result: { model: "gpt-5.2", thinking: {...} }

The `thinking` config persists because it exists in the pre-built
`sisyphusAgent`. GPT models ignore `thinking` and need `reasoningEffort`.

The fix: call the agent factory with the resolved model, so the factory
can return the correct provider-specific config:

    buildAgent(createSisyphusAgent, "gpt-5.2")
    // Result: { model: "gpt-5.2", reasoningEffort: "medium" }

Closes #144

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Christopher Tso
2025-12-21 19:09:26 +11:00
committed by GitHub
parent a9459c04bf
commit d7bc817b75
5 changed files with 164 additions and 47 deletions

View File

@@ -1,4 +1,7 @@
import type { AgentConfig } from "@opencode-ai/sdk"
import { isGptModel } from "./types"
const DEFAULT_MODEL = "anthropic/claude-opus-4-5"
const SISYPHUS_SYSTEM_PROMPT = `<Role>
You are "Sisyphus" - Powerful AI Agent with orchestration capabilities from OhMyOpenCode.
@@ -452,16 +455,22 @@ If the user's approach seems problematic:
`
export const sisyphusAgent: AgentConfig = {
description:
"Sisyphus - Powerful AI orchestrator from OhMyOpenCode. Plans obsessively with todos, assesses search complexity before exploration, delegates strategically to specialized agents. Uses explore for internal code (parallel-friendly), librarian only for external docs, and always delegates UI work to frontend engineer.",
mode: "primary",
model: "anthropic/claude-opus-4-5",
thinking: {
type: "enabled",
budgetTokens: 32000,
},
maxTokens: 64000,
prompt: SISYPHUS_SYSTEM_PROMPT,
color: "#00CED1",
export function createSisyphusAgent(model: string = DEFAULT_MODEL): AgentConfig {
const base = {
description:
"Sisyphus - Powerful AI orchestrator from OhMyOpenCode. Plans obsessively with todos, assesses search complexity before exploration, delegates strategically to specialized agents. Uses explore for internal code (parallel-friendly), librarian only for external docs, and always delegates UI work to frontend engineer.",
mode: "primary" as const,
model,
maxTokens: 64000,
prompt: SISYPHUS_SYSTEM_PROMPT,
color: "#00CED1",
}
if (isGptModel(model)) {
return { ...base, reasoningEffort: "medium" }
}
return { ...base, thinking: { type: "enabled", budgetTokens: 32000 } }
}
export const sisyphusAgent = createSisyphusAgent()