status: avoid plugin lookup for direct channel model overrides

This commit is contained in:
Peter Steinberger
2026-04-08 14:16:45 +01:00
parent 96417308cc
commit abe460177d
2 changed files with 39 additions and 1 deletions

View File

@@ -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 },
});

View File

@@ -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) {