refactor: remove dead ultrawork model override code
Remove ultrawork-model-override hook and per-agent ultrawork model swap config that relied on zen opencode.ai free tier (no longer functional). Removed: - src/hooks/ultrawork-model-override/ (hook, test, index) - ultrawork field from AgentOverrideConfigSchema - ultrawork-model-override from HookNameSchema - UltraworkConfig type from model-fallback-types - Non-max20 sonnet+ultrawork-opus codepath from model-fallback - Claude subscription model table from installation docs - All references in plugin-interface, create-session-hooks, schema.json - Related test cases and updated snapshots
This commit is contained in:
@@ -47,4 +47,3 @@ export { createTasksTodowriteDisablerHook } from "./tasks-todowrite-disabler";
|
||||
export { createWriteExistingFileGuardHook } from "./write-existing-file-guard";
|
||||
export { createHashlineReadEnhancerHook } from "./hashline-read-enhancer";
|
||||
|
||||
export { createUltraworkModelOverrideHook } from "./ultrawork-model-override";
|
||||
|
||||
@@ -1,217 +0,0 @@
|
||||
import { describe, expect, it } from "vitest"
|
||||
import { createUltraworkModelOverrideHook } from "./hook"
|
||||
|
||||
interface ChatParamsInput {
|
||||
agent: string
|
||||
message: {
|
||||
variant: string
|
||||
model?: { providerID?: string; modelID?: string }
|
||||
}
|
||||
sessionID?: string
|
||||
}
|
||||
|
||||
interface ChatParamsOutput {
|
||||
// Not used by this hook
|
||||
}
|
||||
|
||||
function createMockParams(overrides: {
|
||||
agent?: string
|
||||
variant?: string
|
||||
model?: { providerID?: string; modelID?: string }
|
||||
sessionID?: string
|
||||
}): { input: ChatParamsInput; output: ChatParamsOutput } {
|
||||
const agent = overrides.agent ?? "sisyphus"
|
||||
const variant = overrides.variant ?? "max"
|
||||
const model = overrides.model
|
||||
const sessionID = overrides.sessionID
|
||||
|
||||
return {
|
||||
input: {
|
||||
agent,
|
||||
message: { variant, model },
|
||||
sessionID,
|
||||
},
|
||||
output: {},
|
||||
}
|
||||
}
|
||||
|
||||
describe("createUltraworkModelOverrideHook", () => {
|
||||
describe("model swap works", () => {
|
||||
it("variant max, ultrawork config exists → model swapped", async () => {
|
||||
// given
|
||||
const agents = {
|
||||
sisyphus: {
|
||||
ultrawork: {
|
||||
model: "openai/gpt-5.2",
|
||||
},
|
||||
},
|
||||
}
|
||||
const hook = createUltraworkModelOverrideHook({ agents })
|
||||
const { input, output } = createMockParams({})
|
||||
|
||||
// when
|
||||
await hook["chat.params"](input, output)
|
||||
|
||||
// then
|
||||
expect(input.message.model).toEqual({
|
||||
providerID: "openai",
|
||||
modelID: "gpt-5.2",
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("no-op on non-max variant", () => {
|
||||
it("variant high → model unchanged", async () => {
|
||||
// given
|
||||
const agents = {
|
||||
sisyphus: {
|
||||
ultrawork: {
|
||||
model: "openai/gpt-5.2",
|
||||
},
|
||||
},
|
||||
}
|
||||
const hook = createUltraworkModelOverrideHook({ agents })
|
||||
const { input, output } = createMockParams({ variant: "high" })
|
||||
|
||||
// when
|
||||
await hook["chat.params"](input, output)
|
||||
|
||||
// then
|
||||
expect(input.message.model).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe("no-op without config", () => {
|
||||
it("agent has no ultrawork config → model unchanged", async () => {
|
||||
// given
|
||||
const agents = {
|
||||
hephaestus: {
|
||||
ultrawork: {
|
||||
model: "openai/gpt-5.2",
|
||||
},
|
||||
},
|
||||
}
|
||||
const hook = createUltraworkModelOverrideHook({ agents })
|
||||
const { input, output } = createMockParams({})
|
||||
|
||||
// when
|
||||
await hook["chat.params"](input, output)
|
||||
|
||||
// then
|
||||
expect(input.message.model).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe("empty ultrawork config", () => {
|
||||
it("ultrawork: {} → no-op (model required)", async () => {
|
||||
// given
|
||||
const agents = {
|
||||
sisyphus: {
|
||||
ultrawork: undefined,
|
||||
},
|
||||
}
|
||||
const hook = createUltraworkModelOverrideHook({ agents })
|
||||
const { input, output } = createMockParams({})
|
||||
|
||||
// when
|
||||
await hook["chat.params"](input, output)
|
||||
|
||||
// then
|
||||
expect(input.message.model).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe("model string parsing", () => {
|
||||
it("openai/gpt-5.2 → { providerID: openai, modelID: gpt-5.2 }", async () => {
|
||||
// given
|
||||
const agents = {
|
||||
sisyphus: {
|
||||
ultrawork: {
|
||||
model: "openai/gpt-5.2",
|
||||
},
|
||||
},
|
||||
}
|
||||
const hook = createUltraworkModelOverrideHook({ agents })
|
||||
const { input, output } = createMockParams({})
|
||||
|
||||
// when
|
||||
await hook["chat.params"](input, output)
|
||||
|
||||
// then
|
||||
expect(input.message.model).toEqual({
|
||||
providerID: "openai",
|
||||
modelID: "gpt-5.2",
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("nested slashes", () => {
|
||||
it("google-vertex-anthropic/claude-opus-4-6 → { providerID: google-vertex-anthropic, modelID: claude-opus-4-6 } (first / only)", async () => {
|
||||
// given
|
||||
const agents = {
|
||||
sisyphus: {
|
||||
ultrawork: {
|
||||
model: "google-vertex-anthropic/claude-opus-4-6",
|
||||
},
|
||||
},
|
||||
}
|
||||
const hook = createUltraworkModelOverrideHook({ agents })
|
||||
const { input, output } = createMockParams({})
|
||||
|
||||
// when
|
||||
await hook["chat.params"](input, output)
|
||||
|
||||
// then
|
||||
expect(input.message.model).toEqual({
|
||||
providerID: "google-vertex-anthropic",
|
||||
modelID: "claude-opus-4-6",
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("variant override", () => {
|
||||
it("ultrawork.variant exists → message.variant updated", async () => {
|
||||
// given
|
||||
const agents = {
|
||||
sisyphus: {
|
||||
ultrawork: {
|
||||
model: "openai/gpt-5.2",
|
||||
variant: "high",
|
||||
},
|
||||
},
|
||||
}
|
||||
const hook = createUltraworkModelOverrideHook({ agents })
|
||||
const { input, output } = createMockParams({})
|
||||
|
||||
// when
|
||||
await hook["chat.params"](input, output)
|
||||
|
||||
// then
|
||||
expect(input.message.variant).toBe("high")
|
||||
})
|
||||
})
|
||||
|
||||
describe("agent name normalization", () => {
|
||||
it("Sisyphus (Ultraworker) → sisyphus config key lookup", async () => {
|
||||
// given
|
||||
const agents = {
|
||||
sisyphus: {
|
||||
ultrawork: {
|
||||
model: "openai/gpt-5.2",
|
||||
},
|
||||
},
|
||||
}
|
||||
const hook = createUltraworkModelOverrideHook({ agents })
|
||||
const { input, output } = createMockParams({ agent: "Sisyphus (Ultraworker)" })
|
||||
|
||||
// when
|
||||
await hook["chat.params"](input, output)
|
||||
|
||||
// then
|
||||
expect(input.message.model).toEqual({
|
||||
providerID: "openai",
|
||||
modelID: "gpt-5.2",
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,83 +0,0 @@
|
||||
import type { AgentOverrides } from "../../config"
|
||||
import { log } from "../../shared"
|
||||
import { getAgentConfigKey } from "../../shared/agent-display-names"
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null
|
||||
}
|
||||
|
||||
function getUltraworkConfig(agents: AgentOverrides | undefined, configKey: string) {
|
||||
if (!agents) return undefined
|
||||
|
||||
for (const [agentKey, override] of Object.entries(agents)) {
|
||||
if (getAgentConfigKey(agentKey) === configKey) {
|
||||
return override?.ultrawork
|
||||
}
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
export function createUltraworkModelOverrideHook(args: { agents?: AgentOverrides }) {
|
||||
let didLogSpikeInput = false
|
||||
|
||||
return {
|
||||
"chat.params": async (input: unknown, output: unknown): Promise<void> => {
|
||||
if (!didLogSpikeInput) {
|
||||
didLogSpikeInput = true
|
||||
|
||||
const inputRecord = isRecord(input) ? input : null
|
||||
const messageRecord = isRecord(inputRecord?.message) ? inputRecord.message : null
|
||||
|
||||
log("ultrawork-model-override spike: raw chat.params input", {
|
||||
inputType: typeof input,
|
||||
outputType: typeof output,
|
||||
hasMessage: messageRecord !== null,
|
||||
messageKeys: messageRecord ? Object.keys(messageRecord) : [],
|
||||
hasMessageModel: messageRecord ? "model" in messageRecord : false,
|
||||
messageModelType: messageRecord ? typeof messageRecord.model : "undefined",
|
||||
})
|
||||
}
|
||||
|
||||
if (!isRecord(input)) return
|
||||
|
||||
const message = input.message
|
||||
if (!isRecord(message)) return
|
||||
if (message.variant !== "max") return
|
||||
|
||||
const agentName = input.agent
|
||||
if (typeof agentName !== "string") return
|
||||
|
||||
const configKey = getAgentConfigKey(agentName)
|
||||
const ultrawork = getUltraworkConfig(args.agents, configKey)
|
||||
if (!ultrawork?.model) return
|
||||
|
||||
const separatorIndex = ultrawork.model.indexOf("/")
|
||||
const providerID = separatorIndex === -1 ? ultrawork.model : ultrawork.model.slice(0, separatorIndex)
|
||||
const modelID = separatorIndex === -1 ? "" : ultrawork.model.slice(separatorIndex + 1)
|
||||
|
||||
const previousModel = isRecord(message.model)
|
||||
? {
|
||||
providerID:
|
||||
typeof message.model.providerID === "string" ? message.model.providerID : undefined,
|
||||
modelID: typeof message.model.modelID === "string" ? message.model.modelID : undefined,
|
||||
}
|
||||
: undefined
|
||||
|
||||
message.model = { providerID, modelID }
|
||||
|
||||
if (ultrawork.variant !== undefined) {
|
||||
message.variant = ultrawork.variant
|
||||
}
|
||||
|
||||
log("ultrawork-model-override: swapped model", {
|
||||
sessionID: typeof input.sessionID === "string" ? input.sessionID : undefined,
|
||||
agent: agentName,
|
||||
configKey,
|
||||
from: previousModel,
|
||||
to: message.model,
|
||||
variant: message.variant,
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export { createUltraworkModelOverrideHook } from "./hook"
|
||||
Reference in New Issue
Block a user