fix(ultrawork): respect variant-only schema overrides
Allow ultrawork overrides configured with only variant to apply at message time so thinking level is honored even without model replacement.
This commit is contained in:
@@ -131,7 +131,7 @@ describe("resolveUltraworkOverride", () => {
|
||||
expect(result).toBeNull()
|
||||
})
|
||||
|
||||
test("should return null when ultrawork.model is not set", () => {
|
||||
test("should resolve variant-only override when ultrawork.model is not set", () => {
|
||||
//#given
|
||||
const config = createConfig("sisyphus", { variant: "max" })
|
||||
const output = createOutput("ultrawork do something")
|
||||
@@ -140,7 +140,7 @@ describe("resolveUltraworkOverride", () => {
|
||||
const result = resolveUltraworkOverride(config, "sisyphus", output)
|
||||
|
||||
//#then
|
||||
expect(result).toBeNull()
|
||||
expect(result).toEqual({ variant: "max" })
|
||||
})
|
||||
|
||||
test("should handle model string with multiple slashes", () => {
|
||||
@@ -295,6 +295,22 @@ describe("applyUltraworkModelOverrideOnMessage", () => {
|
||||
expect(dbOverrideSpy).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test("should apply variant-only override when no message ID", () => {
|
||||
//#given
|
||||
const config = createConfig("sisyphus", { variant: "high" })
|
||||
const output = createOutput("ultrawork do something")
|
||||
const tui = createMockTui()
|
||||
|
||||
//#when
|
||||
applyUltraworkModelOverrideOnMessage(config, "sisyphus", output, tui)
|
||||
|
||||
//#then
|
||||
expect(output.message.model).toBeUndefined()
|
||||
expect(output.message["variant"]).toBe("high")
|
||||
expect(output.message["thinking"]).toBe("high")
|
||||
expect(dbOverrideSpy).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test("should not apply override when no keyword detected", () => {
|
||||
//#given
|
||||
const config = createConfig("sisyphus", { model: "anthropic/claude-opus-4-6" })
|
||||
|
||||
@@ -30,8 +30,8 @@ function showToast(tui: unknown, title: string, message: string): void {
|
||||
}
|
||||
|
||||
export type UltraworkOverrideResult = {
|
||||
providerID: string
|
||||
modelID: string
|
||||
providerID?: string
|
||||
modelID?: string
|
||||
variant?: string
|
||||
}
|
||||
|
||||
@@ -58,7 +58,13 @@ export function resolveUltraworkOverride(
|
||||
const agentConfigKey = getAgentConfigKey(rawAgentName)
|
||||
const agentConfig = pluginConfig.agents[agentConfigKey as keyof AgentOverrides]
|
||||
const ultraworkConfig = agentConfig?.ultrawork
|
||||
if (!ultraworkConfig?.model) return null
|
||||
if (!ultraworkConfig?.model && !ultraworkConfig?.variant) return null
|
||||
|
||||
if (!ultraworkConfig.model) {
|
||||
return {
|
||||
variant: ultraworkConfig.variant,
|
||||
}
|
||||
}
|
||||
|
||||
const modelParts = ultraworkConfig.model.split("/")
|
||||
if (modelParts.length < 2) return null
|
||||
@@ -92,6 +98,14 @@ export function applyUltraworkModelOverrideOnMessage(
|
||||
const override = resolveUltraworkOverride(pluginConfig, inputAgentName, output)
|
||||
if (!override) return
|
||||
|
||||
if (!override.providerID || !override.modelID) {
|
||||
if (override.variant) {
|
||||
output.message["variant"] = override.variant
|
||||
output.message["thinking"] = override.variant
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
const messageId = output.message["id"] as string | undefined
|
||||
if (!messageId) {
|
||||
log("[ultrawork-model-override] No message ID found, falling back to direct mutation")
|
||||
|
||||
Reference in New Issue
Block a user