Commit c1f3705
committed
feat(config): execute_threshold_tokens for absolute-token execute thresholds
Adds execute_threshold_tokens as an alternative to execute_threshold_percentage.
Per-model map (with optional 'default' key) of absolute token counts; when a
model matches, tokens config overrides percentage and is clamped to 80% of the
resolved context limit. Requires a known context_limit to convert to percentage.
Core:
- resolveExecuteThresholdDetail() is now the single source of truth returning
{ percentage, mode, absoluteTokens?, matchedKey? }. resolveExecuteThreshold()
is a thin back-compat wrapper.
- Clamp warnings dedupe by (session, model, tokenVal, cap) so over-cap configs
don't spam the log on every transform pass.
- Runtime guards (isFinitePositive) block NaN/negative/zero contextLimit and
token values from poisoning the resolver; all bad inputs fall through to
percentage config safely.
Call-site integration:
- scheduler.ts/transform.ts/event-handler.ts/hook.ts/create-session-hooks.ts:
thread tokensConfig + contextLimit through the execute path.
- execute-status.ts: /ctx-status now uses the detail resolver for mode display
(fixes progressive base-model lookup drift where e.g. gpt-5.4-fast matching
gpt-5.4 was mislabeled as percentage mode).
- rpc-handlers.ts + rpc-types.ts: StatusDetail exposes executeThresholdMode and
executeThresholdTokens so TUI can verify token mode and show the absolute
trigger.
- nudger.ts: intentionally stays percentage-only (advisory only; scheduler is
authoritative). Documented inline.
Config + docs:
- schema: execute_threshold_tokens per-model map (min 5K, max 2M).
- assets/magic-context.schema.json regenerated with drop_tool_structure,
compaction_markers, and experimental fields that were previously missing.
- CONFIGURATION.md: documents both percentage and token modes and their
interaction.
- dashboard ConfigEditor: new per-model text field for execute_threshold_tokens
(alwaysObject + numericText so saved shape stays schema-valid); fixed
drop_tool_structure default display, stale execute_threshold_percentage
slider min (35→20), and added missing memory.retrieval_count_promotion_threshold.
- PerModelField: adds alwaysObject and numericText props for fields whose
schema forbids bare scalars or requires numeric values.
Tests: +10 targeted cases for token-mode detail resolution, progressive
base-model matching, clamp behavior, NaN/zero/negative guards, and dedupe
stability. Suite is 571 pass (was 561).1 parent b14f4dc commit c1f3705
19 files changed
Lines changed: 872 additions & 53 deletions
File tree
- assets
- packages
- dashboard/src/components/ConfigEditor
- plugin
- scripts
- src
- config/schema
- features/magic-context
- hooks/magic-context
- plugin
- hooks
- tui/data
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
72 | | - | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
93 | 95 | | |
94 | 96 | | |
95 | 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 | + | |
96 | 129 | | |
97 | 130 | | |
98 | 131 | | |
| |||
109 | 142 | | |
110 | 143 | | |
111 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
112 | 173 | | |
113 | 174 | | |
114 | 175 | | |
| |||
201 | 262 | | |
202 | 263 | | |
203 | 264 | | |
204 | | - | |
| 265 | + | |
205 | 266 | | |
206 | 267 | | |
207 | 268 | | |
208 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
209 | 277 | | |
210 | 278 | | |
211 | 279 | | |
| |||
256 | 324 | | |
257 | 325 | | |
258 | 326 | | |
259 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
260 | 330 | | |
261 | 331 | | |
262 | 332 | | |
263 | 333 | | |
264 | 334 | | |
265 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
266 | 338 | | |
267 | 339 | | |
268 | 340 | | |
| |||
323 | 395 | | |
324 | 396 | | |
325 | 397 | | |
| 398 | + | |
326 | 399 | | |
327 | 400 | | |
328 | 401 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
77 | 93 | | |
78 | 94 | | |
79 | 95 | | |
| |||
93 | 109 | | |
94 | 110 | | |
95 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
96 | 117 | | |
97 | 118 | | |
98 | 119 | | |
| |||
140 | 161 | | |
141 | 162 | | |
142 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
143 | 241 | | |
144 | 242 | | |
145 | 243 | | |
| |||
Lines changed: 17 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| |||
205 | 206 | | |
206 | 207 | | |
207 | 208 | | |
208 | | - | |
| 209 | + | |
209 | 210 | | |
210 | 211 | | |
211 | 212 | | |
| |||
592 | 593 | | |
593 | 594 | | |
594 | 595 | | |
595 | | - | |
| 596 | + | |
596 | 597 | | |
597 | 598 | | |
598 | 599 | | |
599 | 600 | | |
600 | | - | |
| 601 | + | |
601 | 602 | | |
602 | 603 | | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
603 | 616 | | |
604 | 617 | | |
605 | 618 | | |
| |||
0 commit comments