Merge branch 'feat/noa-experimental':noa 实验性上下文压缩

This commit is contained in:
Autumn-27 committed 2026-09-15 12:09:24 -04:00
commit 95bcd4ef9c
13 files changed
+181 -6

No files matched your search

+9
View File
@@ -36,6 +36,7 @@ type Planner struct {
workDir string // shared work dir (surfaced in prompt as artifact-output target)
injectConstraints func() bool // resolver: inject task operation constraints into system prompt? (nil = yes)
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)
compactor *Compactor // cold-node compaction (§7); nil = disabled
@@ -64,6 +65,11 @@ func (p *Planner) SetNonStreaming(fn func() bool) { p.nonStreamingFn = fn }
func (p *Planner) nonStreaming() bool { return p.nonStreamingFn != nil && p.nonStreamingFn() }
// 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 (p *Planner) SetNoaEnabled(fn func() bool) { p.noaEnabledFn = fn }
// SetMaxTokens wires a resolver for the per-reply output cap. nil/unset or 0 =
// send no cap and let the endpoint decide. Read per run, like nonStreaming.
func (p *Planner) SetMaxTokens(fn func() int) { p.maxTokensFn = fn }
@@ -430,6 +436,9 @@ func (p *Planner) Plan(ctx context.Context, taskID int64, as *db.AssetStore, ts
opts.Transcript = p.tx
opts.SessionID = fmt.Sprintf("exp%d-planner", ts.ID())
}
// 实验功能:开启后由 noa 接管上下文压缩(归档集中在 <workDir>/noa/<SessionID> 下,持久)。
noaSession := fmt.Sprintf("exp%d-planner", ts.ID())
enableNoa(&opts, p.noaEnabledFn, p.workDir, noaSession, noaWarn(noaSession))
// 态势(刚完成的意图 + 完整图)现在拼进本轮 user 输入(见下方 input)。user 里还有
// 指令 + 跨唤醒待办(todo 是模型自己的规划便签,可再生,放 user 即可)。
// 开场白按「本轮有无具体变动」分两种:有变动 → 指向下方【实际变动】块;无变动