feat(skills): curator 健壮性加固 + 评审模型可配置 + 手动触发体验

调度健壮性:
- 技能进化总开关 skill_evolution.enabled 真正生效;CuratorConfig
  与 CuratorSubConfig 默认 enabled 改为 false(显式 opt-in)
- 新增 per-user 运行锁(.curator_state 的 running/started_at),
  防定时器与手动触发并发重复运行;6h stale 检测防进程残留死锁
- maybe_run_curator 改用 ThreadPoolExecutor 限并发(上限 5),
  防首次部署所有用户同时到期的惊群
- 首次运行持续失败时按 6h 退避重试,不再每个 tick 烧 LLM 配额
- should_run_now 时间解析容忍 naive 时间串;损坏的 last_run_at
  触发重跑而非永久死锁
- SkillStore 新增 list_published_names 批量接口,curator 一轮
  只查一次 published,取代逐技能查库

LLM 评审超时:
- _run_llm_review 给 agent.invoke 套整体超时
  (curator.review_timeout_seconds,默认 600s),超时中止本次评审
  并在 curator 日志输出,curator 正常收尾、释放运行锁
- copy_context 把 user 上下文传入工作线程

模型可配置:
- 新增 curator.model_name;curator 评审与技能安全审核共用该模型,
  未配置则回退主模型
- 移除独立的 moderation_model_name 配置
- 前端进化面板新增模型下拉选择器

手动触发体验:
- /api/curator/run 派发后台线程前先预检,返回 {triggered, reason},
  不再无论开关状态都提示"已开始"
- 前端:总开关/curator 开关未开时禁用"立即执行"按钮,
  被预检拦下时按原因(开关未开 / 已有任务在跑)给出准确提示

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
xuhdandClaude Opus 4.7 committed 2026-05-16 15:50:15 +08:00
1 parent 5a25dd08f6
commit 39def1c20b
16 files changed
+448 -65

No files matched your search

+8 -2
View File
@@ -28,11 +28,17 @@ export async function updateCuratorConfig(
return response.json() as Promise<CuratorConfig>;
}
export async function runCurator(): Promise<{ triggered: boolean; message: string }> {
export interface RunCuratorResult {
triggered: boolean;
/** 未触发时的原因代码:evolution_disabled / curator_disabled / already_running。 */
reason: string | null;
}
export async function runCurator(): Promise<RunCuratorResult> {
const response = await apiFetch(`${getBackendBaseURL()}/api/curator/run`, {
method: "POST",
});
return response.json();
return response.json() as Promise<RunCuratorResult>;
}
export async function getCuratorLogs(): Promise<CuratorLogs> {
+3 -1
View File
@@ -3,11 +3,13 @@ export interface CuratorSubConfig {
interval_hours: number;
stale_after_days: number;
archive_after_days: number;
review_timeout_seconds: number;
/** curator 评审使用的模型名;null = 用主模型。 */
model_name: string | null;
}
export interface CuratorConfig {
enabled: boolean;
moderation_model_name: string | null;
curator: CuratorSubConfig;
}
+10 -3
View File
@@ -557,6 +557,12 @@ export const enUS: Translations = {
total: "Total",
runNow: "Run now",
runStarted: "Background run started",
runBlockedEvolutionDisabled:
"Skill evolution is off — enable it below to run the curator.",
runBlockedCuratorDisabled:
"The curator is off — enable it below to run it manually.",
runBlockedAlreadyRunning: "A curator run is already in progress.",
runDisabledHint: "Enable skill evolution and the curator below first.",
lastActions: "Last run",
llmSuggested: "LLM suggested (self-report)",
actuallyDid: "Actually done (tool calls)",
@@ -581,9 +587,10 @@ export const enUS: Translations = {
archiveAfterDaysLabel: "Archive threshold (days)",
archiveAfterDaysHelper:
"Stale skills inactive for this many additional days are archived.",
moderationModelLabel: "Moderation model (optional)",
moderationModelHelper:
"Leave blank to use the default chat model.",
curatorModelLabel: "Curator review model",
curatorModelHelper:
"Model for the curator's LLM review and skill security moderation. Defaults to the primary model.",
curatorModelDefault: "Primary model (default)",
save: "Save changes",
saveSuccess: "Configuration updated",
reset: "Reset",
+7 -2
View File
@@ -482,6 +482,10 @@ export interface Translations {
total: string;
runNow: string;
runStarted: string;
runBlockedEvolutionDisabled: string;
runBlockedCuratorDisabled: string;
runBlockedAlreadyRunning: string;
runDisabledHint: string;
lastActions: string;
llmSuggested: string;
actuallyDid: string;
@@ -500,8 +504,9 @@ export interface Translations {
staleAfterDaysHelper: string;
archiveAfterDaysLabel: string;
archiveAfterDaysHelper: string;
moderationModelLabel: string;
moderationModelHelper: string;
curatorModelLabel: string;
curatorModelHelper: string;
curatorModelDefault: string;
save: string;
saveSuccess: string;
reset: string;
+7 -2
View File
@@ -533,6 +533,10 @@ export const zhCN: Translations = {
total: "合计",
runNow: "立即执行",
runStarted: "已触发后台执行",
runBlockedEvolutionDisabled: "自我进化未开启 —— 请先在下方打开开关。",
runBlockedCuratorDisabled: "curator 未开启 —— 请先在下方打开 curator 开关。",
runBlockedAlreadyRunning: "已有一次 curator 运行进行中。",
runDisabledHint: "请先在下方开启自我进化与 curator 开关。",
lastActions: "最近一次运行",
llmSuggested: "LLM 建议(自述)",
actuallyDid: "实际执行(工具调用)",
@@ -552,8 +556,9 @@ export const zhCN: Translations = {
staleAfterDaysHelper: "技能长时间不活跃后被标记为陈旧。",
archiveAfterDaysLabel: "归档阈值(天)",
archiveAfterDaysHelper: "标记陈旧后再经过这么多天会被自动归档。",
moderationModelLabel: "安全审核模型(可选)",
moderationModelHelper: "为空时使用默认主模型。",
curatorModelLabel: "技能优化模型",
curatorModelHelper: "用于 curator 技能评审和技能安全审核的模型,为空则使用主模型。",
curatorModelDefault: "主模型(默认)",
save: "保存修改",
saveSuccess: "配置已更新",
reset: "重置",