@@ -415,7 +342,7 @@ export function RoutingReliabilitySection({
{t('Scheduled channel tests')}
{t(
- 'Automatically probe all channels in the background'
+ 'Run background checks using the selected test mode'
)}
@@ -501,7 +428,7 @@ export function RoutingReliabilitySection({
? t(
'How frequently the system checks auto-disabled channels for recovery'
)
- : t('How frequently the system tests all channels')}
+ : t('Time between scheduled channel checks')}
@@ -542,7 +469,7 @@ export function RoutingReliabilitySection({
{t('Re-enable on success')}
{t(
- 'Bring channels back online after successful checks'
+ 'Successful scheduled or bulk checks can restore automatically disabled channels. Manually disabled channels stay disabled.'
)}
@@ -573,7 +500,9 @@ export function RoutingReliabilitySection({
{t('Disable on failure')}
- {t('Automatically disable channels when tests fail')}
+ {t(
+ 'Apply disable rules to upstream request errors and scheduled or bulk health checks'
+ )}
@@ -591,7 +520,9 @@ export function RoutingReliabilitySection({
name='ChannelDisableThreshold'
render={({ field }) => (
- {t('Disable threshold (seconds)')}
+
+ {t('Health check timeout threshold (seconds)')}
+
{t(
- 'Automatically disable channels exceeding this response time'
+ 'Scheduled or bulk health checks can disable a channel when this duration is exceeded, if both global and channel auto-disable are enabled.'
)}
diff --git a/web/src/features/system-settings/request-policies/decision-record.tsx b/web/src/features/system-settings/request-policies/decision-record.tsx
new file mode 100644
index 0000000000..f8c7e8e645
--- /dev/null
+++ b/web/src/features/system-settings/request-policies/decision-record.tsx
@@ -0,0 +1,54 @@
+import { useTranslation } from 'react-i18next'
+
+import type { PolicyEvent } from './api'
+import { policyLabel } from './policy-label'
+
+export function PolicyDecisionRecord(props: {
+ events: PolicyEvent[] | null
+ channelNames?: Record
+}) {
+ const { t } = useTranslation()
+ return (
+
+ {(props.events ?? []).map((event, index) => (
+
+
+ {index + 1}
+
+
+ {policyLabel(t, event.decision.reason)}
+ {event.channel_id
+ ? ` · ${props.channelNames?.[event.channel_id] ?? `#${event.channel_id}`}`
+ : ''}
+ {event.status && event.decision.action === 'failure'
+ ? ` · HTTP ${event.status}`
+ : ''}
+
+
+ {event.attempt > 0 ? `${t('Attempt')} ${event.attempt} · ` : ''}
+ {event.elapsed_ms} ms
+ {event.group ? ` · ${event.group}` : ''}
+ {event.rule ? ` · ${event.rule}` : ''}
+ {event.status ? ` · HTTP ${event.status}` : ''}
+
+
+ {t('Source')}: {policyLabel(t, event.decision.source)}
+ {event.health ? ` · ${policyLabel(t, event.health)}` : ''}
+
+
+ ))}
+
+ )
+}
diff --git a/web/src/features/system-settings/request-policies/defaults.ts b/web/src/features/system-settings/request-policies/defaults.ts
new file mode 100644
index 0000000000..95237ac995
--- /dev/null
+++ b/web/src/features/system-settings/request-policies/defaults.ts
@@ -0,0 +1,72 @@
+/*
+Copyright (C) 2023-2026 QuantumNous
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+
+For commercial licensing, please contact support@quantumnous.com
+*/
+import type { ChannelAffinitySettings } from '../general/channel-affinity/types'
+import type { SecuritySettings } from '../types'
+
+export type RetrySettings = {
+ RetryTimes: number
+ AutomaticRetryStatusCodes: string
+}
+export type HealthSettings = {
+ ChannelDisableThreshold: string
+ AutomaticDisableChannelEnabled: boolean
+ AutomaticEnableChannelEnabled: boolean
+ AutomaticDisableKeywords: string
+ AutomaticDisableStatusCodes: string
+ 'monitor_setting.auto_test_channel_enabled': boolean
+ 'monitor_setting.auto_test_channel_minutes': number
+ 'monitor_setting.channel_test_concurrency': number
+ 'monitor_setting.channel_test_mode':
+ | 'scheduled_all'
+ | 'auto_ban_only'
+ | 'passive_recovery'
+}
+export type FilteringSettings = Pick<
+ SecuritySettings,
+ 'CheckSensitiveEnabled' | 'CheckSensitiveOnPromptEnabled' | 'SensitiveWords'
+>
+export type RequestPolicySettings = RetrySettings &
+ HealthSettings &
+ FilteringSettings &
+ Pick
+
+export const defaultRequestPolicySettings: RequestPolicySettings = {
+ RetryTimes: 0,
+ AutomaticRetryStatusCodes:
+ '100-199,300-399,401-407,409-499,500-503,505-523,525-599',
+ ChannelDisableThreshold: '',
+ AutomaticDisableChannelEnabled: false,
+ AutomaticEnableChannelEnabled: false,
+ AutomaticDisableKeywords: '',
+ AutomaticDisableStatusCodes: '401',
+ 'monitor_setting.auto_test_channel_enabled': false,
+ 'monitor_setting.auto_test_channel_minutes': 10,
+ 'monitor_setting.channel_test_concurrency': 1,
+ 'monitor_setting.channel_test_mode': 'scheduled_all',
+ 'channel_affinity_setting.enabled': false,
+ 'channel_affinity_setting.session_mode': '',
+ 'channel_affinity_setting.switch_on_success': true,
+ 'channel_affinity_setting.keep_on_channel_disabled': false,
+ 'channel_affinity_setting.max_entries': 100000,
+ 'channel_affinity_setting.default_ttl_seconds': 3600,
+ 'channel_affinity_setting.rules': '[]',
+ CheckSensitiveEnabled: false,
+ CheckSensitiveOnPromptEnabled: false,
+ SensitiveWords: '',
+}
diff --git a/web/src/features/system-settings/request-policies/index.tsx b/web/src/features/system-settings/request-policies/index.tsx
new file mode 100644
index 0000000000..33624f0aea
--- /dev/null
+++ b/web/src/features/system-settings/request-policies/index.tsx
@@ -0,0 +1,36 @@
+/*
+Copyright (C) 2023-2026 QuantumNous
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+
+For commercial licensing, please contact support@quantumnous.com
+*/
+import { SettingsPage } from '../components/settings-page'
+import { defaultRequestPolicySettings } from './defaults'
+import {
+ getPolicySectionContent,
+ getPolicySectionMeta,
+} from './section-registry'
+
+export function RequestPolicies() {
+ return (
+
+ )
+}
diff --git a/web/src/features/system-settings/request-policies/policy-label.ts b/web/src/features/system-settings/request-policies/policy-label.ts
new file mode 100644
index 0000000000..443ebd9612
--- /dev/null
+++ b/web/src/features/system-settings/request-policies/policy-label.ts
@@ -0,0 +1,79 @@
+import type { TFunction } from 'i18next'
+
+// Labels for the decision events recorded by the backend request policy state
+// (reasons, sources and health), the session behaviors, and the auto-disable
+// sources reported by the channel operations summary.
+export function policyLabel(t: TFunction, value: string): string {
+ switch (value) {
+ case 'upstream_failure':
+ return t('Upstream request failed')
+ case 'request_failed':
+ return t('Request failed')
+ case 'task_failed':
+ return t('Task failed')
+ case 'strict_session':
+ return t('Session behavior prevents switching channels')
+ case 'attempt_budget_exhausted':
+ return t('Total attempt budget exhausted')
+ case 'channel_error':
+ return t('Channel error')
+ case 'unrecognized_status':
+ return t('Unrecognized status code')
+ case 'task_accepted':
+ return t('The task was accepted; submission cannot be replayed')
+ case 'pinned_channel':
+ return t('Fixed channel constraint')
+ case 'local_rejection':
+ return t('Request rejected locally')
+ case 'non_retryable_error':
+ case 'system_retry_exclusion':
+ return t('System retry exclusion')
+ case 'status_not_retryable':
+ return t('Status is outside the retry rules')
+ case 'retry_status_matched':
+ return t('Status matches the retry rules')
+ case 'session_rule_matched':
+ return t('Session rule matched')
+ case 'channel_selected':
+ return t('Channel selected')
+ case 'request_completed':
+ return t('Request completed')
+ case 'stream_not_successful':
+ return t('Stream did not complete successfully')
+ case 'channel':
+ return t('Channel')
+ case 'global':
+ return t('Global default')
+ case 'global_and_channel':
+ return t('Global and channel settings')
+ case 'session_rule':
+ return t('Session rule')
+ case 'system':
+ return t('System constraint')
+ case 'routing':
+ return t('Channel selection')
+ case 'upstream':
+ return t('Upstream response')
+ case 'transport':
+ return t('Upstream connection')
+ case 'local':
+ return t('Local check')
+ case 'channel_constraint':
+ return t('Fixed channel constraint')
+ case 'unchanged':
+ return t('Unchanged')
+ case 'channel_disable_requested':
+ return t('Channel disable requested')
+ case 'key_disable_requested':
+ return t('Current key disable requested')
+ case 'off':
+ case '':
+ return t('Do not keep sessions')
+ case 'prefer':
+ return t('Prefer the original channel, allow switching')
+ case 'strict':
+ return t('Require the original channel')
+ default:
+ return value
+ }
+}
diff --git a/web/src/features/system-settings/request-policies/related-policy-link.tsx b/web/src/features/system-settings/request-policies/related-policy-link.tsx
new file mode 100644
index 0000000000..cc6a4daf44
--- /dev/null
+++ b/web/src/features/system-settings/request-policies/related-policy-link.tsx
@@ -0,0 +1,55 @@
+import { useQuery } from '@tanstack/react-query'
+import { Link } from '@tanstack/react-router'
+import { useTranslation } from 'react-i18next'
+
+import { getChannelOps } from '@/features/channels/api'
+import { ROLE } from '@/lib/roles'
+import { requireServerSuccess } from '@/lib/server-error-message'
+import { useAuthStore } from '@/stores/auth-store'
+
+import { policyLabel } from './policy-label'
+
+export function RelatedPolicyLink(props: { section: 'routing' | 'health' }) {
+ const { t } = useTranslation()
+ const isRoot = useAuthStore(
+ (state) => state.auth.user?.role === ROLE.SUPER_ADMIN
+ )
+ if (!isRoot) return null
+ return (
+
+ {t('Request policies')}
+
+ )
+}
+
+export function ChannelHealthSource(props: { autoBan: boolean }) {
+ const { t } = useTranslation()
+ const query = useQuery({
+ queryKey: ['channel-ops', { autoBan: props.autoBan }],
+ queryFn: async () =>
+ requireServerSuccess(await getChannelOps(props.autoBan)),
+ retry: false,
+ staleTime: 60000,
+ meta: { errorToast: false },
+ })
+ const policy = query.data?.data?.request_policy
+ return (
+ <>
+ {policy ? (
+
+ {policy.automatic_disable
+ ? t('Auto-disable enabled')
+ : t('Auto-disable disabled')}{' '}
+ · {t('Source')}: {policyLabel(t, policy.source)}
+
+ ) : (
+ t('Requires global auto-disable and this channel option.')
+ )}
+
+ >
+ )
+}
diff --git a/web/src/features/system-settings/request-limits/sensitive-words-section.tsx b/web/src/features/system-settings/request-policies/request-checks-section.tsx
similarity index 58%
rename from web/src/features/system-settings/request-limits/sensitive-words-section.tsx
rename to web/src/features/system-settings/request-policies/request-checks-section.tsx
index a3ddaa6da2..287c2ec649 100644
--- a/web/src/features/system-settings/request-limits/sensitive-words-section.tsx
+++ b/web/src/features/system-settings/request-policies/request-checks-section.tsx
@@ -22,6 +22,7 @@ import { useForm } from 'react-hook-form'
import { useTranslation } from 'react-i18next'
import * as z from 'zod'
+import { Alert, AlertDescription } from '@/components/ui/alert'
import {
Form,
FormControl,
@@ -33,15 +34,18 @@ import {
} from '@/components/ui/form'
import { Switch } from '@/components/ui/switch'
import { Textarea } from '@/components/ui/textarea'
+import { handleServerError } from '@/lib/handle-server-error'
import {
SettingsForm,
+ SettingsControlGroup,
+ SettingsControlChildren,
SettingsSwitchContent,
SettingsSwitchItem,
} from '../components/settings-form-layout'
import { SettingsPageFormActions } from '../components/settings-page-context'
import { SettingsSection } from '../components/settings-section'
-import { useUpdateOption } from '../hooks/use-update-option'
+import { useSavePolicy } from './use-save-policy'
const sensitiveSchema = z.object({
CheckSensitiveEnabled: z.boolean(),
@@ -51,15 +55,15 @@ const sensitiveSchema = z.object({
type SensitiveFormValues = z.infer
-type SensitiveWordsSectionProps = {
+type RequestChecksSectionProps = {
defaultValues: SensitiveFormValues
}
-export function SensitiveWordsSection({
+export function RequestChecksSection({
defaultValues,
-}: SensitiveWordsSectionProps) {
+}: RequestChecksSectionProps) {
const { t } = useTranslation()
- const updateOption = useUpdateOption()
+ const updateOption = useSavePolicy()
const form = useForm({
resolver: zodResolver(sensitiveSchema),
defaultValues,
@@ -75,21 +79,51 @@ export function SensitiveWordsSection({
value !== defaultValues[key as keyof SensitiveFormValues]
)
- for (const [key, value] of updates) {
- await updateOption.mutateAsync({ key, value: value ?? '' })
+ try {
+ if (updates.length > 0) {
+ await updateOption.mutateAsync(
+ Object.fromEntries(
+ updates.map(([key, value]) => [key, String(value ?? '')])
+ )
+ )
+ }
+ } catch (error) {
+ handleServerError(error)
}
}
return (
-
+
+
+ {t('Source: global settings. Changes take effect after saving.')}
+
+ {t('Request text filtering')}
+
+ {t(
+ 'Checks text extracted from supported requests against keywords, ignoring case. A match rejects the request before upstream processing and does not affect channel health. Images, audio and generated responses are not checked.'
+ )}
+