返回 DeepSeek-Reasonix
compact_settings.go
根目录 / internal / agent / compact_settings.go
1 package agent
2
3 // compactionThreshold keeps construction-time values immutable. A live source
4 // must be concurrency-safe; children snapshot it before their Agent is built.
5 type compactionThreshold struct {
6 initial float64
7 current func() float64
8 }
9
10 func (s compactionThreshold) ratio() float64 {
11 if s.current != nil {
12 return s.current()
13 }
14 return s.initial
15 }
16
17 // CompactRatio reports the same live threshold used by each compaction decision.
18 // Standalone agents without a source retain their construction-time behavior.
19 func (a *Agent) CompactRatio() float64 {
20 if a.compactRatioSource == nil {
21 return a.compactRatio
22 }
23 if ratio := a.compactRatioSource(); ratio > 0 {
24 return ratio
25 }
26 return defaultCompactRatio
27 }
28
28 lines GO