feat(settings): 增加实验功能开关,可开启 noa 上下文压缩
系统设置新增「实验功能」区块,内含 noa 模型驱动上下文压缩开关(默认关)。 开启后平台接入的四类 agent(planner / worker / 主 agent / 对话)由 noa 接管 上下文压缩,取代内置 compaction;关闭即恢复内置压缩。 - agent: 新增 enableNoa 共享接入器(noaadapter.Enable 唯一入口,all-or-nothing), 四类 agent 各加 noaEnabledFn 解析器 + SetNoaEnabled,每 run 读一次,切换只影响 之后启动的 run,无需重建 agent。归档落在各 agent 本 run 工作目录下(任务级持久), session id 与 transcript 同规则。启用失败经 onWarn 上报并回退内置压缩,不中断任务。 - server: settings key noa_compaction + Manager 读写;8 处 agent 装配点注入平台级 解析器(server 5 + task_llm 3);GET/PUT /api/settings 增加字段。 - web: 系统设置页新增实验功能卡片与开关(乐观更新、失败回滚),类型与 mock 补字段。 官方默认行为不变:开关默认关闭时 noaadapter.Enable 不被调用,内置 compaction 原样工作。
This commit is contained in:
1 parent
4ae319feca
commit
865d52267d
11 files changed
+177
-1
No files matched your search
@@ -30,9 +30,15 @@ type MainAgent struct {
|
||||
workDir string // shared work dir (surfaced in prompt as artifact-output target)
|
||||
steerWork func(intentID int64, msg string) error // engine callback: steer a running work (nil = off)
|
||||
nonStreamingFn func() bool // resolver: use non-streaming (Complete) path? (nil = streaming)
|
||||
noaEnabledFn func() bool // resolver: use experimental noa compaction? (nil = off)
|
||||
maxTokensFn func() int // resolver: per-reply output cap (nil/0 = send no cap)
|
||||
}
|
||||
|
||||
// SetNoaEnabled wires a resolver deciding whether runs use the experimental noa
|
||||
// context-compression mechanism. nil/unset = off (built-in compaction). Read per
|
||||
// run so the settings toggle takes effect without rebuilding the agent.
|
||||
func (m *MainAgent) SetNoaEnabled(fn func() bool) { m.noaEnabledFn = fn }
|
||||
|
||||
// SetNonStreaming wires a resolver deciding whether runs use the non-streaming
|
||||
// model path (true = non-streaming). nil/unset = streaming (default).
|
||||
func (m *MainAgent) SetNonStreaming(fn func() bool) { m.nonStreamingFn = fn }
|
||||
@@ -166,6 +172,13 @@ func (m *MainAgent) Chat(ctx context.Context, taskID int64, mainSeg int, as *db.
|
||||
opts.SessionID = fmt.Sprintf("exp%d-main-s%d", ts.ID(), mainSeg)
|
||||
}
|
||||
}
|
||||
// 实验功能:开启后由 noa 接管上下文压缩(归档落在本任务 mainDir 下,任务级持久)。
|
||||
// session id 与 transcript 同规则(分段感知),使归档与恢复对齐。
|
||||
noaSession := fmt.Sprintf("exp%d-main", ts.ID())
|
||||
if mainSeg > 0 {
|
||||
noaSession = fmt.Sprintf("exp%d-main-s%d", ts.ID(), mainSeg)
|
||||
}
|
||||
enableNoa(&opts, m.noaEnabledFn, mainDir, noaSession, noaWarn(noaSession))
|
||||
ctx = attachSideCapture(ctx, &opts)
|
||||
s := agentcore.NewSession(opts)
|
||||
defer s.Close()
|
||||
|
||||
Reference in new issue
Block a user