Commit da2a401
authored
fix(session): retry resumed turns that fail against an expired Cursor agent (#52)
* fix(session): retry resumed turns that fail against an expired agent
A pooled Cursor agent can pass resume() yet fail the subsequent send when
Cursor's server has already expired it — surfacing as `Cursor run ended
with status "error"` after a session sits idle. acquireAgent only wrapped
resumeAgent() in its create-fallback, so a successful-resume-then-failed-send
went uncaught and failed the turn (server retention is shorter than our local
7-day reuse window and is undocumented).
agentRun now wraps the resumed-turn stream: on a resumed turn that throws
before emitting any event (and is not aborted), it re-creates a fresh agent,
replays the full transcript, and re-pools under the same session, overwriting
the dead agentId. Guarded to a single attempt; never retries a fresh-create
turn, an already-emitting stream, or a user abort.
* chore(session): add debug traces and tidy retry path
- Trace retry trigger under OPENCODE_CURSOR_DEBUG
- Log original resume failure when it cannot ride along as cause
- Document that retry fires on any error class (Cursor's
status:"error" carries no machine-readable class); bounded to
one attempt
- Drop unused resetSessionPoolMemory import in tests1 parent 0bca2ca commit da2a401
2 files changed
Lines changed: 442 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
190 | 193 | | |
191 | 194 | | |
192 | 195 | | |
| |||
200 | 203 | | |
201 | 204 | | |
202 | 205 | | |
203 | | - | |
204 | 206 | | |
205 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
206 | 213 | | |
207 | 214 | | |
208 | 215 | | |
| |||
212 | 219 | | |
213 | 220 | | |
214 | 221 | | |
| 222 | + | |
| 223 | + | |
215 | 224 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
220 | 293 | | |
221 | | - | |
| 294 | + | |
222 | 295 | | |
223 | 296 | | |
224 | 297 | | |
| |||
0 commit comments