🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat: configure channel decision models in service settings (#21788)
AmAzing-d241e6bd6700
diff --git a/.agents/ux/lobe-design-rules.md b/.agents/ux/lobe-design-rules.mdindex 7eebb407953..6ab7c14dd82 100644--- a/.agents/ux/lobe-design-rules.md+++ b/.agents/ux/lobe-design-rules.md@@ -105,3 +105,11 @@ Source: acceptance round 4 review — Discord comparisons for composer, typing lChannel join events identify people and Agents using their own avatars, not a generic invitation icon. Render each avatar beside its member name, including every member in a grouped event. Let member pairs wrap at narrow widths; do not detach the avatar stack from the names or silently omit later avatars. A member’s emoji avatar is identity, even when it resembles a warning symbol.Source: user clarification during acceptance round 6 (2026-10-27).++## LOBE-UX-015 — Feature-gated settings follow the feature's availability++An unreleased feature's settings, search results and settings summary counts use the same per-user feature flag as the feature itself. Channel decision settings are visible only when `serverConfigSelectors.enableChannels` is true; a default-on preference does not bypass the `channel` rollout gate.++Enforcement: `src/features/SettingsSearch/items.test.ts` covers the channel decision search entry with the flag off and on. The service-model form filters the channel row before deriving its groups and counts.++Source: user correction about the unreleased Channel feature (2026-10-28).diff --git a/apps/server/src/services/channel/README.md b/apps/server/src/services/channel/README.mdindex 9c4aa2e2bc1..e40a2f4eadf 100644--- a/apps/server/src/services/channel/README.md+++ b/apps/server/src/services/channel/README.md@@ -8,7 +8,7 @@ still bypass classification. Agent replies never trigger another classification.Configure a TypeSafe API key through the deployment's \`TYPESAFE_API_KEY\` environment variable,or in the sender's provider settings (workspace provider settings in workspace scope).-Then opt in through the existing service-model settings:+Routing is enabled by default. Configure its switch and decision model in Settings → Service Models → Advanced → Channels:```json{@@ -27,8 +27,8 @@ TYPESAFE_API_KEY="your-typesafe-api-key"# SYSTEM_AGENT="channelRouting=openrouter/typesafe/jev-1.13"```-An explicit model/provider selection opts in; `enabled: false` opts out even when the deployment-sets a model. The default is disabled; `SYSTEM_AGENT=default=...` never fills this non-chat slot.+The service-model switch controls routing; `enabled: false` opts out even when the deployment+sets a model. The default is enabled; `SYSTEM_AGENT=default=...` never fills this non-chat slot.When disabled at send time, the existing all-candidate fallback remains. A message already waitingfor model classification when routing is disabled becomes unassigned rather than broadcasting.An unmentioned Thread reply waits for its root's routing decision before choosing candidates;diff --git a/apps/server/src/services/channel/routingConfig.test.ts b/apps/server/src/services/channel/routingConfig.test.tsindex 4f305b0deb7..b0b8bb70f96 100644--- a/apps/server/src/services/channel/routingConfig.test.ts+++ b/apps/server/src/services/channel/routingConfig.test.ts@@ -1,4 +1,5 @@// @vitest-environment node+import { DEFAULT_SYSTEM_AGENT_CONFIG } from '@lobechat/const';import { afterEach, describe, expect, it, vi } from 'vitest';import { resolveChannelRoutingConfig } from './routingConfig';@@ -19,25 +20,41 @@ afterEach(() => {});describe('Channel service model configuration', () => {- it('does not enable a paid classifier by default', async () => {- expect(await resolveChannelRoutingConfig({} as never, 'user')).toBeNull();+ it('enables the distribution decision model by default', async () => {+ const { model, provider } = DEFAULT_SYSTEM_AGENT_CONFIG.channelRouting;+ expect(await resolveChannelRoutingConfig({} as never, 'user')).toEqual({ model, provider });});it('uses the explicit Jev default when opted in', async () => {settings.mockResolvedValue({ systemAgent: { channelRouting: { enabled: true } } });expect(await resolveChannelRoutingConfig({} as never, 'user')).toEqual({- model: 'jev-1.14.0',- provider: 'typesafe',+ model: DEFAULT_SYSTEM_AGENT_CONFIG.channelRouting.model,+ provider: DEFAULT_SYSTEM_AGENT_CONFIG.channelRouting.provider,});});it('supports deployment selection and never inherits a generic chat default', async () => {env.SYSTEM_AGENT = 'default=openai/gpt-5';- expect(await resolveChannelRoutingConfig({} as never, 'user')).toBeNull();+ expect(await resolveChannelRoutingConfig({} as never, 'user')).toEqual({+ model: DEFAULT_SYSTEM_AGENT_CONFIG.channelRouting.model,+ provider: DEFAULT_SYSTEM_AGENT_CONFIG.channelRouting.provider,+ });env.SYSTEM_AGENT += ',channelRouting=openrouter/typesafe/jev-1.13';expect(await resolveChannelRoutingConfig({} as never, 'user')).toEqual({model: 'typesafe/jev-1.13',provider: 'openrouter',});});+ it('prefers a saved decision model over the deployment choice', async () => {+ env.SYSTEM_AGENT = 'channelRouting=typesafe/jev-1.14.0';+ settings.mockResolvedValue({+ systemAgent: {+ channelRouting: { enabled: true, model: 'custom-decision', provider: 'custom' },+ },+ });+ expect(await resolveChannelRoutingConfig({} as never, 'user')).toEqual({+ model: 'custom-decision',+ provider: 'custom',+ });+ });it('honors an explicit user opt-out over deployment configuration', async () => {env.SYSTEM_AGENT = 'channelRouting=typesafe/jev-1.14.0';settings.mockResolvedValue({ systemAgent: { channelRouting: { enabled: false } } });diff --git a/apps/server/src/services/channel/routingConfig.ts b/apps/server/src/services/channel/routingConfig.tsindex 3e10f2209ff..82bb02c4607 100644--- a/apps/server/src/services/channel/routingConfig.ts+++ b/apps/server/src/services/channel/routingConfig.ts@@ -7,7 +7,7 @@ import { appEnv } from '@/envs/app';import { parseSystemAgent } from '@/server/globalConfig/parseSystemAgent';/**- * An explicit service-model selection enables routing; enabled:false always opts out.+ * Routing is enabled by default; enabled:false always opts out.* SYSTEM_AGENT=default=... never assigns a chat model to this decision-only slot.* Credentials still resolve as the actual message sender in the Channel's workspace.*/@@ -17,7 +17,7 @@ export const resolveChannelRoutingConfig = async (db: LobeChatDatabase, userId:const task: Partial<SystemAgentItem> | undefined = systemAgent?.channelRouting;const deployment = parseSystemAgent(appEnv.SYSTEM_AGENT).channelRouting;const defaults = DEFAULT_SYSTEM_AGENT_CONFIG.channelRouting;- const enabled = task?.enabled ?? Boolean(deployment || (task?.model && task.provider));+ const enabled = task?.enabled ?? defaults.enabled;if (!enabled) return null;return {model: task?.model || deployment?.model || defaults.model,diff --git a/locales/en-US/channel.json b/locales/en-US/channel.jsonindex 316a23a9c10..a2a57992dd2 100644--- a/locales/en-US/channel.json+++ b/locales/en-US/channel.json@@ -118,6 +118,7 @@"receipt.errorUnavailable": "No detailed reason was recorded. Check the Agent’s model and device settings before sending again.","receipt.failedHint": "Mention it again to retry.","recipients.all": "All {{count}} Agents will reply",+ "recipients.automatic": "The decision model will choose which Agents reply","recipients.many": "{{first}}, {{second}} and {{count}} more will reply","recipients.named": "{{names}} will reply","recipients.noAgents": "No Agent in this channel can reply",diff --git a/locales/en-US/setting.json b/locales/en-US/setting.jsonindex 37073f9ca60..c60a70cddcc 100644--- a/locales/en-US/setting.json+++ b/locales/en-US/setting.json@@ -1851,6 +1851,8 @@"systemAgent.asr.modelDesc": "Transcribes voice messages to Claude Code and other external agents, which only accept text. Voice input for those agents stays hidden while no model is set or its provider is not enabled.","systemAgent.asr.placeholder": "Select a speech-to-text model","systemAgent.asr.title": "Voice Message Transcription",+ "systemAgent.channelRouting.modelDesc": "Choose which Agents reply to messages without @mentions. When off, all eligible Agents reply.",+ "systemAgent.channelRouting.title": "Channel decision model","systemAgent.customPrompt.addPrompt": "Add Custom Prompt","systemAgent.customPrompt.desc": "Once filled out, the system agent will use the custom prompt when generating content","systemAgent.customPrompt.placeholder": "Please enter custom prompt",diff --git a/locales/zh-CN/channel.json b/locales/zh-CN/channel.jsonindex 21b5f5317a6..9aaf90cc4ad 100644--- a/locales/zh-CN/channel.json+++ b/locales/zh-CN/channel.json@@ -118,6 +118,7 @@"receipt.errorUnavailable": "未记录具体原因,请检查 Agent 的模型与设备设置后重新发送。","receipt.failedHint": "再次 @ 它即可重试。","recipients.all": "全部 {{count}} 位 Agent 都会回复",+ "recipients.automatic": "将由决策模型选择回复的 Agent","recipients.many": "{{first}}、{{second}} 等 {{total}} 位 Agent 会回复","recipients.named": "{{names}} 会回复","recipients.noAgents": "频道里没有可以回复的 Agent",diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.jsonindex e27fabb9f42..8318510f268 100644--- a/locales/zh-CN/setting.json+++ b/locales/zh-CN/setting.json@@ -1851,6 +1851,8 @@"systemAgent.asr.modelDesc": "把发给 Claude Code 等外部 Agent 的语音消息转成文字(它们只接受文本)。未设置模型或其服务商未启用时,这些 Agent 不显示语音消息入口。","systemAgent.asr.placeholder": "选择语音转写模型","systemAgent.asr.title": "语音消息转写",+ "systemAgent.channelRouting.modelDesc": "为未 @ 成员的消息选择回复的 Agent。关闭后,所有符合条件的 Agent 都会回复。",+ "systemAgent.channelRouting.title": "频道决策模型","systemAgent.customPrompt.addPrompt": "添加自定义提示","systemAgent.customPrompt.desc": "填写后,系统助理将在生成内容时使用自定义提示","systemAgent.customPrompt.placeholder": "请输入自定义提示词",diff --git a/packages/business/const/src/llm.ts b/packages/business/const/src/llm.tsindex 15aea88f8af..8d62421da36 100644--- a/packages/business/const/src/llm.ts+++ b/packages/business/const/src/llm.ts@@ -1,3 +1,7 @@+/** Decision model selecting the Agents that reply in a channel. */+export const DEFAULT_CHANNEL_ROUTING_MODEL = 'jev-1.14.0';+export const DEFAULT_CHANNEL_ROUTING_PROVIDER = 'typesafe';+export const DEFAULT_EMBEDDING_PROVIDER = 'openai';export const DEFAULT_MODEL = 'deepseek-v4-flash';diff --git a/packages/const/src/settings/systemAgent.test.ts b/packages/const/src/settings/systemAgent.test.tsnew file mode 100644index 00000000000..8cb90270bd9--- /dev/null+++ b/packages/const/src/settings/systemAgent.test.ts@@ -0,0 +1,20 @@+import type * as BusinessDefaults from '@lobechat/business-const';+import { describe, expect, it, vi } from 'vitest';++import { DEFAULT_SYSTEM_AGENT_CONFIG } from './systemAgent';++vi.mock('@lobechat/business-const', async (importOriginal) => ({+ ...(await importOriginal<typeof BusinessDefaults>()),+ DEFAULT_CHANNEL_ROUTING_MODEL: undefined,+ DEFAULT_CHANNEL_ROUTING_PROVIDER: undefined,+}));++describe('channel decision defaults with an older distribution overlay', () => {+ it('retains the enabled self-hosted fallback when the overlay has no decision defaults', () => {+ expect(DEFAULT_SYSTEM_AGENT_CONFIG.channelRouting).toEqual({+ enabled: true,+ model: 'jev-1.14.0',+ provider: 'typesafe',+ });+ });+});diff --git a/packages/const/src/settings/systemAgent.ts b/packages/const/src/settings/systemAgent.tsindex 9111e0ef0d9..65adeccdbea 100644--- a/packages/const/src/settings/systemAgent.ts+++ b/packages/const/src/settings/systemAgent.ts@@ -7,6 +7,7 @@ import {DEFAULT_VERIFY_MODEL,DEFAULT_VERIFY_PROVIDER,} from '@lobechat/business-const';+import * as businessDefaults from '@lobechat/business-const';import type {PromptRewriteSystemAgent,ServiceModelTier,@@ -75,10 +76,22 @@ export const DEFAULT_VERIFY_SYSTEM_AGENT_ITEM: SystemAgentItem = {provider: DEFAULT_VERIFY_PROVIDER,};+// Distribution overlays can deploy separately from the core. Read the new defaults+// optionally so an older overlay can still build with the self-hosted fallback.+const channelRoutingModel: unknown = Reflect.get(businessDefaults, 'DEFAULT_CHANNEL_ROUTING_MODEL');+const channelRoutingProvider: unknown = Reflect.get(+ businessDefaults,+ 'DEFAULT_CHANNEL_ROUTING_PROVIDER',+);+export const DEFAULT_SYSTEM_AGENT_CONFIG: UserServiceModelConfig = {agentMeta: DEFAULT_SYSTEM_AGENT_ITEM,asr: DEFAULT_ASR_SYSTEM_AGENT_ITEM,- channelRouting: { enabled: false, model: 'jev-1.14.0', provider: 'typesafe' },+ channelRouting: {+ enabled: true,+ model: typeof channelRoutingModel === 'string' ? channelRoutingModel : 'jev-1.14.0',+ provider: typeof channelRoutingProvider === 'string' ? channelRoutingProvider : 'typesafe',+ },expertise: DEFAULT_SYSTEM_AGENT_ITEM,followUpAction: DEFAULT_FOLLOW_UP_ACTION_SYSTEM_AGENT_ITEM,generationTopic: DEFAULT_MINI_SYSTEM_AGENT_ITEM,diff --git a/packages/locales/src/default/channel.ts b/packages/locales/src/default/channel.tsindex ef51ab4abfe..177b4d4ef72 100644--- a/packages/locales/src/default/channel.ts+++ b/packages/locales/src/default/channel.ts@@ -1,4 +1,6 @@export default {+ 'recipients.automatic': 'The decision model will choose which Agents reply',+'people.empty': 'All available workspace members have joined','people.noMatches': 'No matching workspace members','people.searchMore': 'Showing the first 50 members. Search to find more.',diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.tsindex 3afd5fb0817..3f536a819be 100644--- a/packages/locales/src/default/setting.ts+++ b/packages/locales/src/default/setting.ts@@ -1,4 +1,8 @@export default {+ 'systemAgent.channelRouting.title': 'Channel decision model',+ 'systemAgent.channelRouting.modelDesc':+ 'Choose which Agents reply to messages without @mentions. When off, all eligible Agents reply.',+'chatPreference.assist.desc':'Personal preferences: they only apply to you, in your personal space and every workspace.','chatPreference.assist.title': 'Chat Assist',diff --git a/src/features/Channels/Composer.tsx b/src/features/Channels/Composer.tsxindex 75449ba51bf..2470d12eb67 100644--- a/src/features/Channels/Composer.tsx+++ b/src/features/Channels/Composer.tsx@@ -75,6 +75,11 @@ export function Composer({const draft = useComposerDraft(editor, draftKey);const shouldSendOnEnter = useEnterToSend();const userId = useUserStore(userProfileSelectors.userId);+ const decisionEnabled = useUserStore(+ (s) =>+ (s.settings.systemAgent?.channelRouting?.enabled ??+ s.defaultSettings.systemAgent.channelRouting.enabled) !== false,+ );const [content, setContent] = useState('');const [mentionIds, setMentionIds] = useState<string[]>([]);const [busy, setBusy] = useState(false);@@ -158,6 +163,7 @@ export function Composer({<ComposerRecipientsrecipients={composerRecipients({defaultRecipientIds,+ decisionEnabled,inThread,members: members.map((member) => ({actorType: member.actorType,diff --git a/src/features/Channels/recipients.test.ts b/src/features/Channels/recipients.test.tsindex aef5dc0fadd..7d1165fdef6 100644--- a/src/features/Channels/recipients.test.ts+++ b/src/features/Channels/recipients.test.ts@@ -82,3 +82,27 @@ describe('composerRecipients', () => {).toBe('noFollowers');});});++describe('decision routing preview', () => {+ const base = {+ defaultRecipientIds: ['analyst', 'coder'],+ decisionEnabled: true,+ inThread: false,+ members: [member('analyst'), member('coder')],+ mentionIds: [],+ };+ it('does not promise every candidate will reply while routing is enabled', () => {+ expect(composerRecipients(base)).toEqual({ agents: [], kind: 'automatic' });+ expect(composerRecipients({ ...base, inThread: true })).toEqual({+ agents: [],+ kind: 'automatic',+ });+ });+ it('keeps explicit mentions and the disabled fallback accurate', () => {+ expect(composerRecipients({ ...base, mentionIds: ['coder'] })).toEqual({+ agents: [member('coder')],+ kind: 'named',+ });+ expect(composerRecipients({ ...base, decisionEnabled: false }).kind).toBe('all');+ });+});diff --git a/src/features/Channels/recipients.ts b/src/features/Channels/recipients.tsindex e8203827402..55b7b5485ee 100644--- a/src/features/Channels/recipients.ts+++ b/src/features/Channels/recipients.ts@@ -10,13 +10,15 @@ export interface ComposerMember {}/**- * - `all`: no mentions on the main conversation, so every Agent replies.+ * - `automatic`: the decision model selects from the eligible Agents.+ * - `all`: routing is off and no Agent is mentioned, so every eligible Agent replies.* - `named`: the mentioned Agents, or the Thread's followers.* - `peopleOnly`: only people are mentioned, which wakes no Agent.* - `noFollowers`: a Thread nobody follows yet; a mention invites an Agent.* - `noAgents`: the main conversation has no active Agent.*/-export type ComposerRecipientKind = 'all' | 'named' | 'noAgents' | 'noFollowers' | 'peopleOnly';+export type ComposerRecipientKind =+ 'automatic' | 'all' | 'named' | 'noAgents' | 'noFollowers' | 'peopleOnly';/*** Who replies if the draft is sent now. Mirrors `sendMessage` in the Channel repository:@@ -25,11 +27,13 @@ export type ComposerRecipientKind = 'all' | 'named' | 'noAgents' | 'noFollowers'*/export const composerRecipients = ({defaultRecipientIds,+ decisionEnabled = false,inThread,members,mentionIds,}: {defaultRecipientIds: string[];+ decisionEnabled?: boolean;inThread: boolean;members: ComposerMember[];mentionIds: string[];@@ -42,5 +46,6 @@ export const composerRecipients = ({}const defaults = agents.filter((agent) => defaultRecipientIds.includes(agent.id));if (!defaults.length) return { agents: [], kind: inThread ? 'noFollowers' : 'noAgents' };+ if (decisionEnabled) return { agents: [], kind: 'automatic' };return { agents: defaults, kind: !inThread && defaults.length > 1 ? 'all' : 'named' };};diff --git a/src/features/ServiceModel/ServiceModelForm/SlotRow.tsx b/src/features/ServiceModel/ServiceModelForm/SlotRow.tsxindex c74f3a57c52..ac31041552d 100644--- a/src/features/ServiceModel/ServiceModelForm/SlotRow.tsx+++ b/src/features/ServiceModel/ServiceModelForm/SlotRow.tsx@@ -25,6 +25,7 @@ interface SlotRowProps {state: RowState;/** The picker's accessible name; the row shows the same text as its label. */title: string;+ width?: number;}/**@@ -41,6 +42,7 @@ const SlotRow = ({onChange,state,title,+ width = PICKER_WIDTH,}: SlotRowProps) => {const { t } = useTranslation('setting');const { groups, parseValue } = useModelOptions(modelKind);@@ -84,7 +86,7 @@ const SlotRow = ({disabled={disabled}options={options}// borderless sits 1px further right than a filled trigger; keep the arrows in one line- style={{ flex: 'none', marginInlineEnd: 1, width: PICKER_WIDTH }}+ style={{ flex: 'none', marginInlineEnd: 1, width }}value={value}variant={'borderless'}labelRender={() =>diff --git a/src/features/ServiceModel/ServiceModelForm/index.tsx b/src/features/ServiceModel/ServiceModelForm/index.tsxindex e0657d4fa9a..e93387627d8 100644--- a/src/features/ServiceModel/ServiceModelForm/index.tsx+++ b/src/features/ServiceModel/ServiceModelForm/index.tsx@@ -1,7 +1,7 @@'use client';import { SERVICE_MODEL_TIER_SLOTS } from '@lobechat/const';-import { Button, Flexbox, Icon, InputNumber, TextArea } from '@lobehub/ui';+import { Button, Flexbox, Icon, InputNumber, Switch, TextArea } from '@lobehub/ui';import { Form, type FormGroupItem, useForm } from '@lobehub/ui/form';import * as stylex from '@stylexjs/stylex';import isEqual from 'fast-deep-equal';@@ -17,6 +17,7 @@ import { FORM_STYLE } from '@/const/layoutTokens';import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';import { usePermission } from '@/hooks/usePermission';import { useSaveState } from '@/hooks/useSaveState';+import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';import { useUserStore } from '@/store/user';import {PERSONAL_SYSTEM_AGENT_KEYS,@@ -48,10 +49,10 @@ const DEFAULT_AGENT_ROW = 'defaultAgent';const ADVANCED_ANCHOR = 'service-model-advanced';-/** Onboarding and channel-routing slots are internal and not shown. */+/** Onboarding slots are internal and not shown. */type DisplaySlot = Exclude<UserServiceModelConfigKey,- 'channelRouting' | 'onboardingTaskRecommender' | 'onboardingUnderstanding'+ 'onboardingTaskRecommender' | 'onboardingUnderstanding'>;type RowKey = typeof DEFAULT_AGENT_ROW | DisplaySlot;@@ -73,11 +74,12 @@ const TIERS: { key: ServiceModelTier; modelKind: ModelKind; rows: RowKey[] }[] =const ASR_ROW = 'asr' satisfies RowKey;/** A settings card: one per tier, plus voice. */-type Section = ServiceModelTier | 'voice';+type Section = ServiceModelTier | 'channelRouting' | 'voice';const sectionOf = (row: RowKey | UserServiceModelConfigKey): Section => {if (row === DEFAULT_AGENT_ROW) return 'main';if (row === ASR_ROW) return 'voice';+ if (row === 'channelRouting') return 'channelRouting';return tierOfSlot(row) ?? 'main';};@@ -100,6 +102,7 @@ interface ServiceModelFormProps {const ServiceModelForm = ({ hidePersonalPreferences }: ServiceModelFormProps) => {const { t } = useTranslation('setting');+ const enableChannels = useServerConfigStore(serverConfigSelectors.enableChannels);const { allowed: canManage, reason } = usePermission('manage_settings');const [storedSystemAgent, storedDefaultAgent, defaults, defaultAgentDefaults] = useUserStore((s) => [@@ -452,6 +455,51 @@ const ServiceModelForm = ({ hidePersonalPreferences }: ServiceModelFormProps) =>},];+ if (enableChannels) {+ const row = 'channelRouting';+ const state = rowState(row);+ const title = t('systemAgent.channelRouting.title');+ groups.push({+ children: (+ <Form.Field label={t('serviceModel.tierPicker')}>+ <Flexbox+ horizontal+ align={'center'}+ gap={12}+ justify={'flex-end'}+ style={{ flex: 'none', width: PICKER_WIDTH }}+ >+ {state.kind !== 'off' && (+ <SlotRow+ canDisable={false}+ disabled={!canManage || saveStatus === 'saving'}+ followLabel={followLabelOf(row)}+ followModel={followModelOf(row)}+ modelKind={'decision'}+ state={state}+ title={title}+ width={PICKER_WIDTH - 48}+ onChange={(choice) => writeSlot(row, choice)}+ />+ )}+ <Switch+ aria-label={title}+ checked={state.kind !== 'off'}+ disabled={!canManage || saveStatus === 'saving'}+ onChange={(enabled) => writeSlotField(row, { enabled })}+ />+ </Flexbox>+ </Form.Field>+ ),+ collapsible: false,+ desc: withReason(t('systemAgent.channelRouting.modelDesc')),+ extra: saveHint(row),+ title: (+ <SettingsSearchAnchor id={'service-model-channelRouting'}>{title}</SettingsSearchAnchor>+ ),+ });+ }+return (<Formcollapsible={false}diff --git a/src/features/ServiceModel/ServiceModelForm/useModelCatalog.tsx b/src/features/ServiceModel/ServiceModelForm/useModelCatalog.tsxindex fa0208bc09b..b46f0aab0c8 100644--- a/src/features/ServiceModel/ServiceModelForm/useModelCatalog.tsx+++ b/src/features/ServiceModel/ServiceModelForm/useModelCatalog.tsx@@ -4,11 +4,12 @@ import { useTranslation } from 'react-i18next';import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';+import { decisionModelProviders } from '../decisionModelProviders';import { type ModelRef } from '../serviceModelState';import ModelLabel from './ModelLabel';/** `vision` is the chat models that can read images. */-export type ModelKind = 'asr' | 'chat' | 'embedding' | 'vision';+export type ModelKind = 'asr' | 'chat' | 'decision' | 'embedding' | 'vision';// lobe-design-ignore DETAIL-NO-EMPTY: with no enabled model the picker still offers its follow item, so the list is never emptyexport const toOptionValue = ({ model, provider }: ModelRef) => `${provider}/${model}`;@@ -19,6 +20,9 @@ export const toOptionValue = ({ model, provider }: ModelRef) => `${provider}/${m*/export const useModelOptions = (kind: ModelKind) => {const { t } = useTranslation('setting');+ const decisionModels = useAiInfraStore((s) => s.enabledAiModels);+ const enabledProviders = useAiInfraStore((s) => s.enabledAiProviders);+ const runtimeConfig = useAiInfraStore((s) => s.aiProviderRuntimeConfig);const providers = useAiInfraStore((s) =>kind === 'embedding'? aiProviderSelectors.enabledEmbeddingModelList(s)@@ -28,7 +32,11 @@ export const useModelOptions = (kind: ModelKind) => {);const groups = useMemo<SelectOptions>(() => {- const withModels = providers+ const candidates =+ kind === 'decision'+ ? decisionModelProviders(decisionModels ?? [], enabledProviders ?? [], runtimeConfig)+ : providers;+ const withModels = candidates.map((provider) =>kind === 'vision'? {@@ -49,7 +57,7 @@ export const useModelOptions = (kind: ModelKind) => {value: toOptionValue({ model: model.id, provider: provider.id }),})),}));- }, [kind, providers, t]);+ }, [decisionModels, enabledProviders, kind, providers, runtimeConfig, t]);/** Option value → model ref; the model id may itself contain slashes. */const parseValue = useCallback((value: string): ModelRef => {diff --git a/src/features/ServiceModel/decisionModelProviders.test.ts b/src/features/ServiceModel/decisionModelProviders.test.tsnew file mode 100644index 00000000000..d5c6826a8d0--- /dev/null+++ b/src/features/ServiceModel/decisionModelProviders.test.ts@@ -0,0 +1,68 @@+import type { EnabledAiModel, EnabledProvider } from 'model-bank';+import { describe, expect, it } from 'vitest';++import { decisionModelProviders } from './decisionModelProviders';++const model = (id: string, patch: Partial<EnabledAiModel> = {}): EnabledAiModel => ({+ abilities: {},+ id,+ providerId: 'typesafe',+ type: 'decision',+ ...patch,+});+const providers: EnabledProvider[] = [{ id: 'typesafe', name: 'TypeSafe', source: 'builtin' }];++describe('decisionModelProviders', () => {+ it('only offers enabled, visible decision models from enabled providers', () => {+ const result = decisionModelProviders(+ [+ model('jev'),+ model('chat', { type: 'chat' }),+ model('disabled', { enabled: false }),+ model('hidden', { visible: false }),+ model('other-provider', { providerId: 'other' }),+ ],+ providers,+ {},+ );+ expect(result.map(({ children }) => children.map(({ id }) => id))).toEqual([['jev']]);+ });++ it.each([undefined, false])(+ 'excludes keyless custom endpoints with fetchOnClient=%s',+ (fetchOnClient) => {+ expect(+ decisionModelProviders([model('jev')], providers, {+ typesafe: {+ config: {},+ settings: {},+ keyVaults: { baseURL: 'http://localhost:8080/v1' },+ fetchOnClient,+ },+ }),+ ).toEqual([]);+ },+ );++ it('keeps server-configured providers when a stale client flag has no client credentials', () => {+ expect(+ decisionModelProviders([model('jev')], providers, {+ typesafe: { config: {}, settings: {}, keyVaults: {}, fetchOnClient: true },+ }),+ ).toHaveLength(1);+ });++ it('excludes client-only providers and empty groups', () => {+ expect(decisionModelProviders([], providers, {})).toEqual([]);+ expect(+ decisionModelProviders([model('jev')], providers, {+ typesafe: {+ config: {},+ settings: {},+ keyVaults: { apiKey: 'test-key' },+ fetchOnClient: true,+ },+ }),+ ).toEqual([]);+ });+});diff --git a/src/features/ServiceModel/decisionModelProviders.ts b/src/features/ServiceModel/decisionModelProviders.tsnew file mode 100644index 00000000000..984de320141--- /dev/null+++ b/src/features/ServiceModel/decisionModelProviders.ts@@ -0,0 +1,25 @@+import type { EnabledAiModel, EnabledProvider } from 'model-bank';+import { isProviderFetchOnClient } from 'model-bank/modelProviders';++import type { AiProviderRuntimeConfig } from '@/types/aiProvider';++/** Channel routing runs on the server, so client-only providers cannot participate. */+export const decisionModelProviders = (+ models: EnabledAiModel[],+ providers: EnabledProvider[],+ runtimeConfig: Record<string, AiProviderRuntimeConfig>,+) =>+ providers+ .filter((provider) => !isProviderFetchOnClient(provider.id, runtimeConfig[provider.id]))+ .map((provider) => ({+ ...provider,+ name: provider.name || provider.id,+ children: models.filter(+ (model) =>+ model.providerId === provider.id &&+ model.type === 'decision' &&+ model.enabled !== false &&+ model.visible !== false,+ ),+ }))+ .filter((provider) => provider.children.length > 0);diff --git a/src/features/ServiceModel/serviceModelState.test.ts b/src/features/ServiceModel/serviceModelState.test.tsindex b534cac3062..7df906b8578 100644--- a/src/features/ServiceModel/serviceModelState.test.ts+++ b/src/features/ServiceModel/serviceModelState.test.ts@@ -187,3 +187,35 @@ describe('canDisableSlot', () => {expect(canDisableSlot('topic')).toBe(false);});});++describe('channel decision settings', () => {+ it('defaults to an enabled decision model independent of chat tiers', () => {+ const stored = applyTierChoice({}, 'flash', FLASH);+ expect(resolveSlotState(stored, defaults, 'channelRouting')).toEqual({+ kind: 'follow',+ tier: undefined,+ value: { model: defaults.channelRouting.model, provider: defaults.channelRouting.provider },+ });+ expect(canDisableSlot('channelRouting')).toBe(true);+ expect(stored.channelRouting).toBeUndefined();+ });++ it('keeps the chosen model while disabled and restores it when enabled', () => {+ const chosen = applySlotChoice({}, 'channelRouting', { kind: 'custom', value: OTHER });+ const off = applySlotChoice(chosen, 'channelRouting', { kind: 'off' });+ expect(off.channelRouting).toEqual({ ...OTHER, enabled: false });+ expect(resolveSlotState(off, defaults, 'channelRouting').kind).toBe('off');+ const on = { ...off, channelRouting: { ...off.channelRouting, enabled: true } };+ expect(resolveSlotState(on, defaults, 'channelRouting')).toEqual({+ kind: 'custom',+ value: OTHER,+ });+ });++ it('restores the recommended decision model without following a chat tier', () => {+ const chosen = applySlotChoice({}, 'channelRouting', { kind: 'custom', value: OTHER });+ const restored = restoreAllSlots(chosen, defaults, ['channelRouting']);+ expect(restored.channelRouting).toEqual({ enabled: true });+ expect(resolveSlotState(restored, defaults, 'channelRouting').kind).toBe('follow');+ });+});diff --git a/src/features/ServiceModel/serviceModelState.ts b/src/features/ServiceModel/serviceModelState.tsindex 2e617dd41b4..78750e7578b 100644--- a/src/features/ServiceModel/serviceModelState.ts+++ b/src/features/ServiceModel/serviceModelState.ts@@ -23,6 +23,7 @@ export interface ModelRef {* feature off. Other slots have no off switch at runtime and get no such option.*/const ENABLED_FLAG_SLOTS = new Set<UserServiceModelConfigKey>([+ 'channelRouting','followUpAction','inputCompletion','promptRewrite',diff --git a/src/features/SettingsSearch/items.test.ts b/src/features/SettingsSearch/items.test.tsindex 15a3b52621e..ac2db766eeb 100644--- a/src/features/SettingsSearch/items.test.ts+++ b/src/features/SettingsSearch/items.test.ts@@ -13,6 +13,7 @@ import {const webContext: SettingsSearchContext = {disableEmailPassword: false,enableBusinessFeatures: true,+ enableChannels: false,enableComposio: true,enableGatewayMode: true,enableWorkspace: false,@@ -25,6 +26,15 @@ const webContext: SettingsSearchContext = {};describe('settings search index', () => {+ it('only exposes the channel decision setting when channels are enabled', () => {+ const item = SETTINGS_SEARCH_ITEMS.find(+ (entry) => entry.labelKey === 'systemAgent.channelRouting.title',+ )!;++ expect(item.visible?.({ ...webContext, enableChannels: false }) ?? true).toBe(false);+ expect(item.visible?.({ ...webContext, enableChannels: true }) ?? true).toBe(true);+ });+it('derives one search item per lab feature in catalog order', () => {const labsItems = SETTINGS_SEARCH_ITEMS.filter((item) => item.tab === SettingsTabs.Labs);diff --git a/src/features/SettingsSearch/items.ts b/src/features/SettingsSearch/items.tsindex 87672e6245a..224bc4f715b 100644--- a/src/features/SettingsSearch/items.ts+++ b/src/features/SettingsSearch/items.ts@@ -12,6 +12,7 @@ export type SettingsSearchTab = SettingsTabs | WorkspaceSettingsTabs;export interface SettingsSearchContext {disableEmailPassword: boolean;enableBusinessFeatures: boolean;+ enableChannels: boolean;enableComposio: boolean;enableGatewayMode: boolean;/** Workspaces are available to this user */@@ -501,6 +502,14 @@ export const SETTINGS_SEARCH_ITEMS: SettingsSearchItem[] = [labelKey: 'systemAgent.asr.title',tab: SettingsTabs.ServiceModel,},+ {+ anchor: 'service-model-channelRouting',+ descKey: 'systemAgent.channelRouting.modelDesc',+ keywords: ['channel', 'decision', 'Jev', '频道', '决策', '回复'],+ labelKey: 'systemAgent.channelRouting.title',+ tab: SettingsTabs.ServiceModel,+ visible: (ctx) => ctx.enableChannels,+ },// Chat Preferences (workspace only — the personal sidebar keeps these rows in// Service Model › Advanced){diff --git a/src/features/SettingsSearch/useSettingsSearch.ts b/src/features/SettingsSearch/useSettingsSearch.tsindex 1ae8f59abbc..4a23dfd304e 100644--- a/src/features/SettingsSearch/useSettingsSearch.ts+++ b/src/features/SettingsSearch/useSettingsSearch.ts@@ -126,6 +126,7 @@ export const useSettingsSearch = (} = scope;const { hideDocs, showAiImage } = useServerConfigStore(featureFlagsSelectors);const enableBusinessFeatures = useServerConfigStore(serverConfigSelectors.enableBusinessFeatures);+ const enableChannels = useServerConfigStore(serverConfigSelectors.enableChannels);const enableGatewayMode = useServerConfigStore(serverConfigSelectors.enableGatewayMode);const enableComposio = useServerConfigStore(serverConfigSelectors.enableComposio);const enableWorkspace = useServerConfigStore(serverConfigSelectors.enableWorkspace);@@ -143,6 +144,7 @@ export const useSettingsSearch = (const ctx: SettingsSearchContext = {disableEmailPassword: !!disableEmailPassword,enableBusinessFeatures: !!enableBusinessFeatures,+ enableChannels,enableComposio: !!enableComposio,enableGatewayMode: !!enableGatewayMode,enableWorkspace: !!enableWorkspace,@@ -307,6 +309,7 @@ export const useSettingsSearch = (t,disableEmailPassword,enableBusinessFeatures,+ enableChannels,enableComposio,enableGatewayMode,enableWorkspace,diff --git a/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap b/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snapindex b04d6ab3b01..60613f341ba 100644--- a/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap+++ b/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap@@ -55,7 +55,7 @@ exports[`settingsSelectors > currentSystemAgent > should merge DEFAULT_SYSTEM_AG"provider": "openai",},"channelRouting": {- "enabled": false,+ "enabled": true,"model": "jev-1.14.0","provider": "typesafe",},