feat(config): allow runtime_fallback to be configured as boolean
Enable simple boolean configuration for runtime_fallback:
- "runtime_fallback": true - Enable with defaults
- "runtime_fallback": false - Disable
- "runtime_fallback": { ... } - Advanced object config (existing)
Updated schema, event handler, chat-message handler, and session hooks
to handle both boolean and object formats.
This commit is contained in:
parent
aff49ef488
commit
9f10997987
@ -44,7 +44,12 @@ export const OhMyOpenCodeConfigSchema = z.object({
|
|||||||
auto_update: z.boolean().optional(),
|
auto_update: z.boolean().optional(),
|
||||||
skills: SkillsConfigSchema.optional(),
|
skills: SkillsConfigSchema.optional(),
|
||||||
ralph_loop: RalphLoopConfigSchema.optional(),
|
ralph_loop: RalphLoopConfigSchema.optional(),
|
||||||
runtime_fallback: RuntimeFallbackConfigSchema.optional(),
|
/**
|
||||||
|
* Enable runtime fallback (default: true)
|
||||||
|
* Set to false to disable, or use object for advanced config:
|
||||||
|
* { "enabled": true, "retry_on_errors": [400, 429], "timeout_seconds": 30 }
|
||||||
|
*/
|
||||||
|
runtime_fallback: z.union([z.boolean(), RuntimeFallbackConfigSchema]).optional(),
|
||||||
background_task: BackgroundTaskConfigSchema.optional(),
|
background_task: BackgroundTaskConfigSchema.optional(),
|
||||||
notification: NotificationConfigSchema.optional(),
|
notification: NotificationConfigSchema.optional(),
|
||||||
babysitting: BabysittingConfigSchema.optional(),
|
babysitting: BabysittingConfigSchema.optional(),
|
||||||
|
|||||||
@ -62,7 +62,9 @@ export function createChatMessageHandler(args: {
|
|||||||
const isRuntimeFallbackEnabled =
|
const isRuntimeFallbackEnabled =
|
||||||
hooks.runtimeFallback !== null &&
|
hooks.runtimeFallback !== null &&
|
||||||
hooks.runtimeFallback !== undefined &&
|
hooks.runtimeFallback !== undefined &&
|
||||||
(pluginConfig.runtime_fallback?.enabled ?? true)
|
(typeof pluginConfig.runtime_fallback === "boolean"
|
||||||
|
? pluginConfig.runtime_fallback
|
||||||
|
: (pluginConfig.runtime_fallback?.enabled ?? true))
|
||||||
|
|
||||||
return async (
|
return async (
|
||||||
input: ChatMessageInput,
|
input: ChatMessageInput,
|
||||||
|
|||||||
@ -121,7 +121,9 @@ export function createEventHandler(args: {
|
|||||||
const isRuntimeFallbackEnabled =
|
const isRuntimeFallbackEnabled =
|
||||||
hooks.runtimeFallback !== null &&
|
hooks.runtimeFallback !== null &&
|
||||||
hooks.runtimeFallback !== undefined &&
|
hooks.runtimeFallback !== undefined &&
|
||||||
(args.pluginConfig.runtime_fallback?.enabled ?? true)
|
(typeof args.pluginConfig.runtime_fallback === "boolean"
|
||||||
|
? args.pluginConfig.runtime_fallback
|
||||||
|
: (args.pluginConfig.runtime_fallback?.enabled ?? true))
|
||||||
|
|
||||||
// Avoid triggering multiple abort+continue cycles for the same failing assistant message.
|
// Avoid triggering multiple abort+continue cycles for the same failing assistant message.
|
||||||
const lastHandledModelErrorMessageID = new Map<string, string>()
|
const lastHandledModelErrorMessageID = new Map<string, string>()
|
||||||
|
|||||||
@ -245,10 +245,15 @@ export function createSessionHooks(args: {
|
|||||||
? safeHook("anthropic-effort", () => createAnthropicEffortHook())
|
? safeHook("anthropic-effort", () => createAnthropicEffortHook())
|
||||||
: null
|
: null
|
||||||
|
|
||||||
|
const runtimeFallbackConfig =
|
||||||
|
typeof pluginConfig.runtime_fallback === "boolean"
|
||||||
|
? { enabled: pluginConfig.runtime_fallback }
|
||||||
|
: pluginConfig.runtime_fallback
|
||||||
|
|
||||||
const runtimeFallback = isHookEnabled("runtime-fallback")
|
const runtimeFallback = isHookEnabled("runtime-fallback")
|
||||||
? safeHook("runtime-fallback", () =>
|
? safeHook("runtime-fallback", () =>
|
||||||
createRuntimeFallbackHook(ctx, {
|
createRuntimeFallbackHook(ctx, {
|
||||||
config: pluginConfig.runtime_fallback,
|
config: runtimeFallbackConfig,
|
||||||
pluginConfig,
|
pluginConfig,
|
||||||
}))
|
}))
|
||||||
: null
|
: null
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user