From b24d153f236ab0ab16e99678f3309c09352456c3 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 22 Apr 2026 06:57:59 +0100 Subject: [PATCH] perf(test): avoid bundled channel fallback in model override tests --- src/channels/model-overrides.test.ts | 3 ++- src/channels/model-overrides.ts | 16 ++++++++-------- src/channels/plugins/setup-helpers.test.ts | 1 + 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/channels/model-overrides.test.ts b/src/channels/model-overrides.test.ts index bc3d6e6e8ae..cfcb8c448fb 100644 --- a/src/channels/model-overrides.test.ts +++ b/src/channels/model-overrides.test.ts @@ -1,12 +1,13 @@ import { beforeEach, describe, expect, it } from "vitest"; import type { OpenClawConfig } from "../config/config.js"; -import { setActivePluginRegistry } from "../plugins/runtime.js"; +import { resetPluginRuntimeStateForTest, setActivePluginRegistry } from "../plugins/runtime.js"; import { createTestRegistry } from "../test-utils/channel-plugins.js"; import { createSessionConversationTestRegistry } from "../test-utils/session-conversation-registry.js"; import { resolveChannelModelOverride } from "./model-overrides.js"; describe("resolveChannelModelOverride", () => { beforeEach(() => { + resetPluginRuntimeStateForTest(); setActivePluginRegistry(createSessionConversationTestRegistry()); }); diff --git a/src/channels/model-overrides.ts b/src/channels/model-overrides.ts index 7425bf25d95..40736738a19 100644 --- a/src/channels/model-overrides.ts +++ b/src/channels/model-overrides.ts @@ -68,15 +68,15 @@ function buildChannelCandidates( normalizeMessageChannel(params.channel ?? "") ?? normalizeOptionalLowercaseString(params.channel); const groupId = normalizeOptionalString(params.groupId); - const sessionConversation = resolveSessionConversationRef(params.parentSessionKey); + const rawParentConversation = parseRawSessionConversationRef(params.parentSessionKey); + const channelPlugin = normalizedChannel ? getChannelPlugin(normalizedChannel) : undefined; const parentOverrideFallbacks = - (normalizedChannel - ? getChannelPlugin( - normalizedChannel, - )?.conversationBindings?.buildModelOverrideParentCandidates?.({ - parentConversationId: sessionConversation?.rawId, - }) - : null) ?? []; + channelPlugin?.conversationBindings?.buildModelOverrideParentCandidates?.({ + parentConversationId: rawParentConversation?.rawId, + }) ?? []; + const sessionConversation = resolveSessionConversationRef(params.parentSessionKey, { + bundledFallback: parentOverrideFallbacks.length === 0, + }); const groupConversationKind = normalizeChatType(params.groupChatType ?? undefined) === "channel" ? "channel" diff --git a/src/channels/plugins/setup-helpers.test.ts b/src/channels/plugins/setup-helpers.test.ts index 4e3f0f1de38..edcd3c0841d 100644 --- a/src/channels/plugins/setup-helpers.test.ts +++ b/src/channels/plugins/setup-helpers.test.ts @@ -54,6 +54,7 @@ function resolveMatrixSingleAccountPromotionTarget(params: { } beforeEach(() => { + resetPluginRuntimeStateForTest(); setActivePluginRegistry( createTestRegistry([ {