feat(agent): 支持为每个 agent 绑定 LLM 配置(agent 级默认模型)

按优先级 Agent 绑定 > 任务/会话指定 > 全局激活 解析每个 agent 运行的模型,
使 planner/worker/goals/mainagent/自定义 agent 可各自走不同 profile(如 plan 用
强模型、work 用弱模型)。未绑定时行为与原先完全一致。

- db: Agent 增 llm_profile_id + SetAgentLLMProfile;schema 幂等兜底 ALTER
- server: 新增 effectiveProfileForAgent/providerForProfile/providerForAgent;
  buildPlannerWorker 让 planner/worker 各自解析 provider;provider 按 profile id
  缓存以共享限速器;goals/会话链同步走绑定;绑定变更热重载
- api: agent 配置接口收 llm_profile_id(三态) + 返回可选 profile 列表
- web: agent 编辑器「配置与提示词」页新增「默认模型」下拉
This commit is contained in:
Autumn-27 committed 2026-08-11 12:15:38 -04:00
1 parent 289cf6a24f
commit c84bba477f
10 files changed
+238 -55

No files matched your search

+1
View File
@@ -421,6 +421,7 @@ export const api = {
saveAgentConfig: (
key: string,
patch: {
llm_profile_id?: number | null; // number=绑定;null=解绑(跟随任务/全局);缺省=不动
max_turns?: number;
run_seconds?: number;
web_search?: boolean;
+3
View File
@@ -456,6 +456,7 @@ export interface Agent {
role: string;
builtin: boolean;
enabled: boolean;
llm_profile_id?: number | null; // 绑定的 LLM 配置;null/absent = 跟随任务/会话/全局
max_turns?: number; // 0 = 无限制
run_seconds?: number; // worker 单次运行墙钟上限(秒);0 = 无限制
web_search?: boolean; // 是否启用网络搜索(受系统全局开关门控)
@@ -490,6 +491,8 @@ export interface AgentDetail {
variables: PromptVar[];
versions: PromptVersion[];
visibility: { mcp: number[]; skill: string[] };
// 可绑定的 LLM 配置候选(供「默认模型」下拉);当前绑定见 agent.llm_profile_id
llm_profiles?: { id: number; name: string; model: string; is_default: boolean }[];
wrapup_prompt?: string; // 已保存的收尾提示词(空=用内置默认)
wrapup_default?: string; // 内置默认收尾提示词(占位/恢复默认)
wrapup_max_turns?: number; // 已保存的收尾轮数(0=用内置默认)