1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//! What a region does under pressure, and how that shows up in the prompt.
//!
//! Three policies that travel together because they answer one question between
//! them - a region that is full has to either drop something or refuse, and
//! which it does decides whether the agent ever finds out. None of them touch
//! `Region`'s state, which is why they are not in with it.
use ;
use RegionKind;
/// Eviction strategy for `SlidingWindow` regions.
///
/// Controls how entries are removed when the window exceeds its `max_items` limit.
/// The choice of strategy affects prompt caching effectiveness: PerItem eviction
/// shifts the message prefix every iteration (breaking cache), while Bulk and
/// Compact keep the prefix stable between eviction events.
/// What a region does when a write does not fit.
///
/// The default is what every region did before this existed: make room. That
/// is the right behaviour for a transcript, where the oldest turn is the least
/// useful thing present and losing it costs nothing anyone will notice.
///
/// It is the wrong behaviour for a region holding material the agent chose to
/// keep. There, silently dropping the oldest entry is a decision about what
/// matters, taken by whichever write happened to arrive when the region was
/// full - and the agent never learns it happened. [`Admission::Reject`] hands
/// that decision back: the write fails, the agent is told the region is full,
/// and it releases what it is finished with before adding more.
/// How much a region's contents move between requests.
///
/// This exists because a provider caches by *prefix*: an entry is readable next
/// time only when every byte in front of it is unchanged, so a block that moves
/// invalidates everything behind it however stable that later content is. The
/// arrangement that pays is stable content first and churn last.
///
/// A region's [`RegionKind`] cannot answer this. A pinned region sounds
/// immutable and is written constantly - `context_write` into a findings region
/// is an ordinary move, and tool routing sends read results straight into one.
/// A compact-history region sounds settled and gains an entry every time
/// compaction fires. Inferring stability from the kind put churn at the front of
/// the prefix and cost a measured 456,860 cache-write tokens against zero
/// reads.
///
/// So the blueprint says. The author knows whether a region is set once at spawn
/// or written every turn, and nothing else does.