Version: 0.9.45.dev.260427

后端:
1. execute 主链路重构为“上下文工具域 + 主动优化候选闭环”——移除 order_guard,粗排后默认进入主动微调,先诊断再从后端候选中选择 move/swap,避免 LLM 自由全局乱搜
2. 工具体系升级为动态注入协议——新增 context_tools_add / remove、工具域与二级包映射、主动优化白名单;schedule / taskclass / web 工具按域按包暴露,msg0 规则包与 execute 上下文同步重写
3. analyze_health 升级为主动优化唯一裁判入口——补齐 rhythm / tightness / profile / feasibility 指标、候选扫描与复诊打分、停滞信号、forced imperfection 判定,并把连续优化状态写回运行态
4. 任务类能力并入新 Agent 执行链——新增 upsert_task_class 写工具与启动注入事务写入;任务类模型补充学科画像与整天屏蔽配置,粗排支持 excluded_days_of_week,steady 策略改为基于目标位置/单日负载/分散度/缓冲的候选打分
5. 运行态与路由补齐优化模式语义——新增 active tool domain/packs、pending context hook、active optimize only、taskclass 写入回盘快照;区分 first_full / global_reopt / local_adjust,并完善首次粗排后默认 refine 的判定

前端:
6. 助手时间线渲染细化——推理内容改为独立 reasoning block,支持与工具/状态/正文按时序交错展示,自动收口折叠,修正 confirm reject 恢复动作

仓库:
7. newAgent 文档整体迁入 docs/backend,补充主动优化执行规划与顺序约束拆解文档,删除旧调试日志文件

PS:这次科研了2天,总算是有些进展了——LLM永远只适合做选择题、判断题,不适合做开放创新题。
This commit is contained in:
Losita
2026-04-27 01:09:37 +08:00
parent 04b5836b39
commit 66c06eed0a
60 changed files with 9163 additions and 1819 deletions

View File

@@ -55,6 +55,19 @@ type PlanDecision struct {
PlanSteps []PlanStep `json:"plan_steps,omitempty"`
NeedsRoughBuild bool `json:"needs_rough_build,omitempty"`
TaskClassIDs []int `json:"task_class_ids,omitempty"`
ContextHook *ContextHook `json:"context_hook,omitempty"`
}
// ContextHook 表示 plan 阶段给 execute 阶段的上下文注入建议。
//
// 职责边界:
// 1. 仅承载“建议激活哪个 domain/packs”不负责真正执行 context_tools_add/remove
// 2. domain 仅允许 schedule/taskclasspacks 仅允许 schedule 的可选包;
// 3. 该结构会在 execute 首轮被消费一次,消费后由后端清空。
type ContextHook struct {
Domain string `json:"domain,omitempty"`
Packs []string `json:"packs,omitempty"`
Reason string `json:"reason,omitempty"`
}
// Normalize 统一清洗规划决策中的字符串字段。
@@ -69,6 +82,9 @@ func (d *PlanDecision) Normalize() {
for i := range d.PlanSteps {
d.PlanSteps[i].Normalize()
}
if d.ContextHook != nil {
d.ContextHook.Normalize()
}
}
// Validate 校验规划决策的最小合法性。
@@ -102,6 +118,9 @@ func (d *PlanDecision) Validate() error {
if len(d.PlanSteps) > 0 {
return fmt.Errorf("%s 动作不应携带 plan_steps", d.Action)
}
if d.ContextHook != nil {
return fmt.Errorf("%s 动作不应携带 context_hook", d.Action)
}
return nil
case PlanActionDone:
if len(d.PlanSteps) == 0 {
@@ -112,6 +131,11 @@ func (d *PlanDecision) Validate() error {
return fmt.Errorf("plan_steps[%d] 非法: %w", i, err)
}
}
if d.ContextHook != nil {
if err := d.ContextHook.Validate(); err != nil {
return err
}
}
return nil
default:
return fmt.Errorf("未知 plan action: %s", d.Action)
@@ -149,3 +173,73 @@ func (s *PlanStep) Validate() error {
}
return nil
}
// Normalize 统一清洗 context hook 字段。
func (h *ContextHook) Normalize() {
if h == nil {
return
}
h.Domain = normalizeContextHookDomain(h.Domain)
h.Reason = strings.TrimSpace(h.Reason)
h.Packs = normalizeContextHookPacks(h.Domain, h.Packs)
}
// Validate 校验 context hook 最小合法性。
func (h *ContextHook) Validate() error {
if h == nil {
return nil
}
h.Normalize()
if h.Domain == "" {
return fmt.Errorf("context_hook.domain 非法,仅支持 schedule/taskclass")
}
if h.Domain == "taskclass" && len(h.Packs) > 0 {
return fmt.Errorf("context_hook.taskclass 暂不支持 packs")
}
return nil
}
func normalizeContextHookDomain(domain string) string {
switch strings.ToLower(strings.TrimSpace(domain)) {
case "schedule":
return "schedule"
case "taskclass":
return "taskclass"
default:
return ""
}
}
func normalizeContextHookPacks(domain string, packs []string) []string {
if domain != "schedule" || len(packs) == 0 {
return nil
}
allowed := map[string]struct{}{
"queue": {},
"mutation": {},
"analyze": {},
"detail_read": {},
"deep_analyze": {},
"web": {},
}
seen := make(map[string]struct{}, len(packs))
result := make([]string, 0, len(packs))
for _, raw := range packs {
pack := strings.ToLower(strings.TrimSpace(raw))
if pack == "" || pack == "core" {
continue
}
if _, ok := allowed[pack]; !ok {
continue
}
if _, exists := seen[pack]; exists {
continue
}
seen[pack] = struct{}{}
result = append(result, pack)
}
if len(result) == 0 {
return nil
}
return result
}