mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-01 08:30:22 +00:00
status: avoid plugin lookup for direct channel model overrides
This commit is contained in:
@@ -229,7 +229,7 @@ describe("buildStatusMessage", () => {
|
||||
channel: "discord",
|
||||
groupId: "123",
|
||||
},
|
||||
sessionKey: "agent:main:discord:channel:123",
|
||||
sessionKey: "agent:main:main",
|
||||
sessionScope: "per-sender",
|
||||
queue: { mode: "collect", depth: 0 },
|
||||
});
|
||||
|
||||
@@ -144,6 +144,32 @@ function buildFeishuParentOverrideCandidates(rawId: string | undefined): string[
|
||||
return [];
|
||||
}
|
||||
|
||||
function resolveDirectChannelModelMatch(params: {
|
||||
providerEntries: Record<string, string>;
|
||||
groupId?: string | null;
|
||||
}): { model: string; matchKey?: string; matchSource?: ChannelMatchSource } | null {
|
||||
const directKeys = buildChannelKeyCandidates(params.groupId);
|
||||
if (directKeys.length === 0) {
|
||||
return null;
|
||||
}
|
||||
const match = resolveChannelEntryMatchWithFallback({
|
||||
entries: params.providerEntries,
|
||||
keys: directKeys,
|
||||
parentKeys: [],
|
||||
wildcardKey: "*",
|
||||
normalizeKey: (value) => normalizeOptionalLowercaseString(value) ?? "",
|
||||
});
|
||||
const raw = match.entry ?? match.wildcardEntry;
|
||||
if (typeof raw !== "string") {
|
||||
return null;
|
||||
}
|
||||
const model = normalizeOptionalString(raw);
|
||||
if (!model) {
|
||||
return null;
|
||||
}
|
||||
return { model, matchKey: match.matchKey, matchSource: match.matchSource };
|
||||
}
|
||||
|
||||
export function resolveChannelModelOverride(
|
||||
params: ChannelModelOverrideParams,
|
||||
): ChannelModelOverride | null {
|
||||
@@ -161,6 +187,18 @@ export function resolveChannelModelOverride(
|
||||
if (!providerEntries) {
|
||||
return null;
|
||||
}
|
||||
const directMatch = resolveDirectChannelModelMatch({
|
||||
providerEntries,
|
||||
groupId: params.groupId,
|
||||
});
|
||||
if (directMatch) {
|
||||
return {
|
||||
channel: normalizeMessageChannel(channel) ?? normalizeOptionalLowercaseString(channel) ?? "",
|
||||
model: directMatch.model,
|
||||
matchKey: directMatch.matchKey,
|
||||
matchSource: directMatch.matchSource,
|
||||
};
|
||||
}
|
||||
|
||||
const { keys, parentKeys } = buildChannelCandidates(params);
|
||||
if (keys.length === 0 && parentKeys.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user