Commit 47bb2db
authored
fix(provider): use a larger stall budget while a Cursor tool is in flight (#86)
* fix(provider): use a larger stall budget while a Cursor tool is in flight
The stream watchdog re-armed only from push(), which fires for the ten
mapped update types. A long shell command, build, or test suite streams
nothing between tool-call-started and tool-call-completed, so a healthy
run was cancelled at the 60s budget and the turn lost.
Split the budget in two: an idle budget (OPENCODE_CURSOR_STALL_MS,
raised 60000 -> 120000) and a tool-phase budget applied while at least
one tool call is open (OPENCODE_CURSOR_TOOL_STALL_MS, default 600000,
0 disables just that bound). A tool-phase stall stays terminal and now
names the tool still in flight.
Also re-arm on any raw SDK update rather than only mapped ones, so
progress/heartbeat types the plugin does not model still count as
liveness. The re-arm runs after the switch so it observes post-mutation
openTools state and always selects the correct budget.
Reconcile openTools on turn-ended and on the forced resend: a dropped
or differently-keyed completion would otherwise pin the turn to the
10-minute budget and name a tool that had already finished.
Harden env parsing: Number("abc") is NaN and NaN <= 0 is false, so the
old guard passed and setTimeout(fn, NaN) fired immediately, stalling
every turn. Non-finite values now fall back to the default; an empty
string still disables, preserving the existing escape hatch.
* fix(provider): cap stall budgets at setTimeout's 32-bit ceiling
A setTimeout delay is stored as a signed 32-bit int, so a value above
2147483647 overflows and Node silently clamps it to 1ms. envMs rejected
NaN and Infinity but passed every other finite value straight through, so
OPENCODE_CURSOR_TOOL_STALL_MS=999999999999 stalled every tool-bearing turn
within milliseconds while reporting "no events for 999999999999ms".
The tool-phase stall message tells operators to raise that same variable,
so the trap was reachable by following the plugin's own advice.
Both budgets are now capped at 2147483647. Verified against a live agent:
with the over-large budget set, a 150s shell call died after 5.6s before
this change and completes normally after it.1 parent 2299bbf commit 47bb2db
4 files changed
Lines changed: 489 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
23 | 43 | | |
24 | 44 | | |
25 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
195 | | - | |
| 195 | + | |
| 196 | + | |
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
| |||
378 | 379 | | |
379 | 380 | | |
380 | 381 | | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
385 | 396 | | |
386 | 397 | | |
387 | 398 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 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 | + | |
68 | 94 | | |
69 | 95 | | |
70 | 96 | | |
| |||
86 | 112 | | |
87 | 113 | | |
88 | 114 | | |
89 | | - | |
90 | | - | |
91 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
92 | 124 | | |
93 | 125 | | |
94 | 126 | | |
95 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
96 | 132 | | |
97 | 133 | | |
98 | 134 | | |
| |||
103 | 139 | | |
104 | 140 | | |
105 | 141 | | |
| 142 | + | |
106 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
107 | 148 | | |
108 | 149 | | |
109 | | - | |
| 150 | + | |
110 | 151 | | |
111 | 152 | | |
112 | 153 | | |
| |||
136 | 177 | | |
137 | 178 | | |
138 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
139 | 183 | | |
140 | 184 | | |
141 | 185 | | |
| |||
144 | 188 | | |
145 | 189 | | |
146 | 190 | | |
| 191 | + | |
147 | 192 | | |
148 | 193 | | |
149 | 194 | | |
| |||
159 | 204 | | |
160 | 205 | | |
161 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
162 | 211 | | |
163 | 212 | | |
164 | 213 | | |
165 | 214 | | |
166 | 215 | | |
167 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
168 | 223 | | |
169 | 224 | | |
170 | 225 | | |
| |||
264 | 319 | | |
265 | 320 | | |
266 | 321 | | |
267 | | - | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
268 | 332 | | |
269 | 333 | | |
270 | 334 | | |
| |||
278 | 342 | | |
279 | 343 | | |
280 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
281 | 348 | | |
282 | 349 | | |
283 | 350 | | |
| |||
0 commit comments