fix(model-fallback): keep model fallback opt-in by default
Restore the runtime default that was introduced for model fallback so unset config no longer enables automatic retries unexpectedly. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
56
src/plugin/hooks/create-session-hooks.test.ts
Normal file
56
src/plugin/hooks/create-session-hooks.test.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { describe, expect, it } from "bun:test"
|
||||
import type { OhMyOpenCodeConfig } from "../../config"
|
||||
import type { ModelCacheState } from "../../plugin-state"
|
||||
import type { PluginContext } from "../types"
|
||||
import { createSessionHooks } from "./create-session-hooks"
|
||||
|
||||
const mockContext = {
|
||||
directory: "/tmp",
|
||||
client: {
|
||||
tui: {
|
||||
showToast: async () => ({}),
|
||||
},
|
||||
session: {
|
||||
get: async () => ({ data: null }),
|
||||
update: async () => ({}),
|
||||
},
|
||||
},
|
||||
} as unknown as PluginContext
|
||||
|
||||
const mockModelCacheState = {} as ModelCacheState
|
||||
|
||||
describe("createSessionHooks", () => {
|
||||
it("keeps model fallback disabled when config is unset", () => {
|
||||
// given
|
||||
const pluginConfig = {} as OhMyOpenCodeConfig
|
||||
|
||||
// when
|
||||
const result = createSessionHooks({
|
||||
ctx: mockContext,
|
||||
pluginConfig,
|
||||
modelCacheState: mockModelCacheState,
|
||||
isHookEnabled: (hookName) => hookName === "model-fallback",
|
||||
safeHookEnabled: true,
|
||||
})
|
||||
|
||||
// then
|
||||
expect(result.modelFallback).toBeNull()
|
||||
})
|
||||
|
||||
it("creates model fallback hook when config explicitly enables it", () => {
|
||||
// given
|
||||
const pluginConfig = { model_fallback: true } as OhMyOpenCodeConfig
|
||||
|
||||
// when
|
||||
const result = createSessionHooks({
|
||||
ctx: mockContext,
|
||||
pluginConfig,
|
||||
modelCacheState: mockModelCacheState,
|
||||
isHookEnabled: (hookName) => hookName === "model-fallback",
|
||||
safeHookEnabled: true,
|
||||
})
|
||||
|
||||
// then
|
||||
expect(result.modelFallback).not.toBeNull()
|
||||
})
|
||||
})
|
||||
@@ -153,7 +153,7 @@ export function createSessionHooks(args: {
|
||||
|
||||
// Model fallback hook (configurable via model_fallback config + disabled_hooks)
|
||||
// This handles automatic model switching when model errors occur
|
||||
const isModelFallbackConfigEnabled = pluginConfig.model_fallback ?? true
|
||||
const isModelFallbackConfigEnabled = pluginConfig.model_fallback ?? false
|
||||
const modelFallback = isModelFallbackConfigEnabled && isHookEnabled("model-fallback")
|
||||
? safeHook("model-fallback", () =>
|
||||
createModelFallbackHook({
|
||||
|
||||
Reference in New Issue
Block a user