Skip to content

Commit fe4493c

Browse files
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 <[email protected]>
1 parent 7f75270 commit fe4493c

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { describe, expect, it } from "bun:test"
2+
import type { OhMyOpenCodeConfig } from "../../config"
3+
import type { ModelCacheState } from "../../plugin-state"
4+
import type { PluginContext } from "../types"
5+
import { createSessionHooks } from "./create-session-hooks"
6+
7+
const mockContext = {
8+
directory: "/tmp",
9+
client: {
10+
tui: {
11+
showToast: async () => ({}),
12+
},
13+
session: {
14+
get: async () => ({ data: null }),
15+
update: async () => ({}),
16+
},
17+
},
18+
} as unknown as PluginContext
19+
20+
const mockModelCacheState = {} as ModelCacheState
21+
22+
describe("createSessionHooks", () => {
23+
it("keeps model fallback disabled when config is unset", () => {
24+
// given
25+
const pluginConfig = {} as OhMyOpenCodeConfig
26+
27+
// when
28+
const result = createSessionHooks({
29+
ctx: mockContext,
30+
pluginConfig,
31+
modelCacheState: mockModelCacheState,
32+
isHookEnabled: (hookName) => hookName === "model-fallback",
33+
safeHookEnabled: true,
34+
})
35+
36+
// then
37+
expect(result.modelFallback).toBeNull()
38+
})
39+
40+
it("creates model fallback hook when config explicitly enables it", () => {
41+
// given
42+
const pluginConfig = { model_fallback: true } as OhMyOpenCodeConfig
43+
44+
// when
45+
const result = createSessionHooks({
46+
ctx: mockContext,
47+
pluginConfig,
48+
modelCacheState: mockModelCacheState,
49+
isHookEnabled: (hookName) => hookName === "model-fallback",
50+
safeHookEnabled: true,
51+
})
52+
53+
// then
54+
expect(result.modelFallback).not.toBeNull()
55+
})
56+
})

src/plugin/hooks/create-session-hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export function createSessionHooks(args: {
153153

154154
// Model fallback hook (configurable via model_fallback config + disabled_hooks)
155155
// This handles automatic model switching when model errors occur
156-
const isModelFallbackConfigEnabled = pluginConfig.model_fallback ?? true
156+
const isModelFallbackConfigEnabled = pluginConfig.model_fallback ?? false
157157
const modelFallback = isModelFallbackConfigEnabled && isHookEnabled("model-fallback")
158158
? safeHook("model-fallback", () =>
159159
createModelFallbackHook({

0 commit comments

Comments
 (0)