fix: stop hardcoded channel fallback and auto-pick sole configured channel (#23357) (thanks @lbo728)

Co-authored-by: lbo728 <extreme0728@gmail.com>
This commit is contained in:
Peter Steinberger
2026-02-22 11:20:33 +01:00
parent e33d7fcd13
commit 1cd3b30907
18 changed files with 355 additions and 91 deletions

View File

@@ -59,6 +59,19 @@ describe("agent delivery helpers", () => {
expect(resolved.resolvedTo).toBe("+1999");
});
it("does not inject a default deliverable channel when session has none", () => {
const plan = resolveAgentDeliveryPlan({
sessionEntry: undefined,
requestedChannel: "last",
explicitTo: undefined,
accountId: undefined,
wantsDelivery: true,
});
expect(plan.resolvedChannel).toBe("webchat");
expect(plan.deliveryTargetMode).toBeUndefined();
});
it("skips outbound target resolution when explicit target validation is disabled", () => {
const plan = resolveAgentDeliveryPlan({
sessionEntry: {

View File

@@ -1,5 +1,4 @@
import type { ChannelOutboundTargetMode } from "../../channels/plugins/types.js";
import { DEFAULT_CHAT_CHANNEL } from "../../channels/registry.js";
import type { OpenClawConfig } from "../../config/config.js";
import type { SessionEntry } from "../../config/sessions.js";
import { normalizeAccountId } from "../../utils/account-id.js";
@@ -59,7 +58,7 @@ export function resolveAgentDeliveryPlan(params: {
if (baseDelivery.channel && baseDelivery.channel !== INTERNAL_MESSAGE_CHANNEL) {
return baseDelivery.channel;
}
return params.wantsDelivery ? DEFAULT_CHAT_CHANNEL : INTERNAL_MESSAGE_CHANNEL;
return INTERNAL_MESSAGE_CHANNEL;
}
if (isGatewayMessageChannel(requestedChannel)) {
@@ -69,7 +68,7 @@ export function resolveAgentDeliveryPlan(params: {
if (baseDelivery.channel && baseDelivery.channel !== INTERNAL_MESSAGE_CHANNEL) {
return baseDelivery.channel;
}
return params.wantsDelivery ? DEFAULT_CHAT_CHANNEL : INTERNAL_MESSAGE_CHANNEL;
return INTERNAL_MESSAGE_CHANNEL;
})();
const deliveryTargetMode = explicitTo