refactor(athena): extract applyModelThinkingConfig shared utility
This commit is contained in:
parent
01331af10c
commit
c4deb6bc5d
@ -1,7 +1,7 @@
|
||||
import type { AgentConfig } from "@opencode-ai/sdk"
|
||||
import type { AgentMode, AgentPromptMetadata } from "../types"
|
||||
import { isGptModel } from "../types"
|
||||
import { createAgentToolRestrictions, type PermissionValue } from "../../shared/permission-compat"
|
||||
import { applyModelThinkingConfig } from "./model-thinking-config"
|
||||
|
||||
const MODE: AgentMode = "primary"
|
||||
|
||||
@ -227,10 +227,6 @@ export function createAthenaAgent(model: string): AgentConfig {
|
||||
color: "#1F8EFA",
|
||||
}
|
||||
|
||||
if (isGptModel(model)) {
|
||||
return { ...base, reasoningEffort: "medium" }
|
||||
}
|
||||
|
||||
return { ...base, thinking: { type: "enabled", budgetTokens: 32000 } }
|
||||
return applyModelThinkingConfig(base, model)
|
||||
}
|
||||
createAthenaAgent.mode = MODE
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import type { AgentConfig } from "@opencode-ai/sdk"
|
||||
import type { AgentMode } from "../types"
|
||||
import { isGptModel } from "../types"
|
||||
import { createAgentToolRestrictions } from "../../shared/permission-compat"
|
||||
import { applyModelThinkingConfig } from "./model-thinking-config"
|
||||
|
||||
const MODE: AgentMode = "subagent"
|
||||
|
||||
@ -43,10 +43,6 @@ export function createCouncilMemberAgent(model: string): AgentConfig {
|
||||
...restrictions,
|
||||
}
|
||||
|
||||
if (isGptModel(model)) {
|
||||
return { ...base, reasoningEffort: "medium" }
|
||||
}
|
||||
|
||||
return { ...base, thinking: { type: "enabled", budgetTokens: 32000 } }
|
||||
return applyModelThinkingConfig(base, model)
|
||||
}
|
||||
createCouncilMemberAgent.mode = MODE
|
||||
|
||||
55
src/agents/athena/model-thinking-config.test.ts
Normal file
55
src/agents/athena/model-thinking-config.test.ts
Normal file
@ -0,0 +1,55 @@
|
||||
import { describe, expect, it } from "bun:test"
|
||||
import type { AgentConfig } from "@opencode-ai/sdk"
|
||||
import { applyModelThinkingConfig } from "./model-thinking-config"
|
||||
|
||||
const BASE_CONFIG: AgentConfig = {
|
||||
name: "test-agent",
|
||||
description: "test",
|
||||
model: "anthropic/claude-opus-4-6",
|
||||
temperature: 0.1,
|
||||
}
|
||||
|
||||
describe("applyModelThinkingConfig", () => {
|
||||
describe("given a GPT model", () => {
|
||||
it("returns reasoningEffort medium", () => {
|
||||
const result = applyModelThinkingConfig(BASE_CONFIG, "gpt-5.2")
|
||||
expect(result).toEqual({ ...BASE_CONFIG, reasoningEffort: "medium" })
|
||||
})
|
||||
|
||||
it("returns reasoningEffort medium for openai-prefixed model", () => {
|
||||
const result = applyModelThinkingConfig(BASE_CONFIG, "openai/gpt-5.2")
|
||||
expect(result).toEqual({ ...BASE_CONFIG, reasoningEffort: "medium" })
|
||||
})
|
||||
})
|
||||
|
||||
describe("given an Anthropic model", () => {
|
||||
it("returns thinking config with budgetTokens 32000", () => {
|
||||
const result = applyModelThinkingConfig(BASE_CONFIG, "anthropic/claude-opus-4-6")
|
||||
expect(result).toEqual({
|
||||
...BASE_CONFIG,
|
||||
thinking: { type: "enabled", budgetTokens: 32000 },
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("given a Google model", () => {
|
||||
it("returns base config unchanged", () => {
|
||||
const result = applyModelThinkingConfig(BASE_CONFIG, "google/gemini-3-pro")
|
||||
expect(result).toBe(BASE_CONFIG)
|
||||
})
|
||||
})
|
||||
|
||||
describe("given a Kimi model", () => {
|
||||
it("returns base config unchanged", () => {
|
||||
const result = applyModelThinkingConfig(BASE_CONFIG, "kimi/kimi-k2.5")
|
||||
expect(result).toBe(BASE_CONFIG)
|
||||
})
|
||||
})
|
||||
|
||||
describe("given a model with no provider prefix", () => {
|
||||
it("returns base config unchanged for non-GPT model", () => {
|
||||
const result = applyModelThinkingConfig(BASE_CONFIG, "gemini-3-pro")
|
||||
expect(result).toBe(BASE_CONFIG)
|
||||
})
|
||||
})
|
||||
})
|
||||
17
src/agents/athena/model-thinking-config.ts
Normal file
17
src/agents/athena/model-thinking-config.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import type { AgentConfig } from "@opencode-ai/sdk"
|
||||
import { isGptModel } from "../types"
|
||||
|
||||
export function applyModelThinkingConfig(base: AgentConfig, model: string): AgentConfig {
|
||||
if (isGptModel(model)) {
|
||||
return { ...base, reasoningEffort: "medium" }
|
||||
}
|
||||
|
||||
const slashIndex = model.indexOf("/")
|
||||
const provider = slashIndex > 0 ? model.substring(0, slashIndex).toLowerCase() : ""
|
||||
|
||||
if (provider === "anthropic") {
|
||||
return { ...base, thinking: { type: "enabled", budgetTokens: 32000 } }
|
||||
}
|
||||
|
||||
return base
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user