cursor 0.2.46: a quiet Run's error says the stream timed out, so Pi retries it (#1075)

Cursor's quiet watchdog (idle and heartbeat-only) now ends its error with "; stream timed out (try again)", so Pi, which classifies a streamed error by its words once the 502 is lost behind a 200, retries the turn within its own budget. The status, limits and failure stay as they were. 0.2.46.

Reviewed at 507b2fd0. Checked Pi's own retry list (earendil-works/pi packages/ai/src/utils/retry.ts on main has "timed? out"; "(try again)" alone matches nothing there). magpie's gateway decides on the 502 status (busyStatus), so its own handling is unchanged. Run (WSL, Bun 1.4.2): packages/cursor bun test 421 pass, 0 fail; bun scripts/check.mjs cursor ok. Not run: scripts/cursor-pi-retry.integration.mjs (needs an installed Pi SDK, loopback only); a real Cursor stall (#550).

Co-authored-by: wuuli <wuuli@users.noreply.github.com>
This commit is contained in:
wuuli
2026-11-13 15:09:02 +08:00
committed by GitHub
co-authored by wuuli
parent 6059fb1990
commit 463bbfe2b6
6 changed files with 175 additions and 9 deletions
+12 -3
View File
@@ -1874,7 +1874,11 @@ for (const path of ["native", "stateless"]) {
const sse = await sseOf(response)
expect(Date.now() - started).toBeLessThan(1000)
expect(sse).toContain("native planning one")
expect(sse).toContain("Cursor went quiet: no message for 0 s, its last message thinking (try again)")
expect(sse).toContain("Cursor went quiet: no message for 0 s, its last message thinking; stream timed out (try again)")
const errors = sse.split("\n\n").filter((s) => s.startsWith("data: {")).map((s) => JSON.parse(s.slice(6)).error).filter(Boolean)
expect(errors).toHaveLength(1)
expect(errors[0].message).toMatch(piRetries)
expect(errors[0].message).toMatch(magpiePassing)
expect(sse).not.toContain("[DONE]")
await until(() => a.closedStreams === 1)
})
@@ -1889,6 +1893,11 @@ for (const path of ["native", "stateless"]) {
const sse = await sseOf(response)
const [, beats] = sse.match(/Cursor went quiet: (\d+) heartbeats and nothing else for \d+ s, its last message thinking/) ?? []
expect(Number(beats)).toBeGreaterThan(0)
const errors = sse.split("\n\n").filter((s) => s.startsWith("data: {")).map((s) => JSON.parse(s.slice(6)).error).filter(Boolean)
expect(errors).toHaveLength(1)
expect(errors[0].message).toMatch(piRetries)
expect(errors[0].message).toMatch(magpiePassing)
expect(sse).not.toContain("[DONE]")
await until(() => a.closedStreams === 1)
})
}
@@ -1912,8 +1921,8 @@ for (const path of ["native", "stateless"]) {
const chat = initial({ stream: true, messages: [{ role: "user", content: "prompt " + secret }] })
const sse = await sseOf(await a.ask(account, chat, { input }))
expect(sse).toMatch(path === "native"
? /Cursor went quiet: \d+ heartbeats and nothing else for \d+ s, its last message checkpoint #1 of the Run, the first of step 1, after blob request ×2, thinking \(try again\)/
: /Cursor went quiet: \d+ heartbeats and nothing else for \d+ s, its last message checkpoint #1 of the Run, after blob request ×2, thinking \(try again\)/)
? /Cursor went quiet: \d+ heartbeats and nothing else for \d+ s, its last message checkpoint #1 of the Run, the first of step 1, after blob request ×2, thinking; stream timed out \(try again\)/
: /Cursor went quiet: \d+ heartbeats and nothing else for \d+ s, its last message checkpoint #1 of the Run, after blob request ×2, thinking; stream timed out \(try again\)/)
await until(() => a.closedStreams === 1)
const files = readdirSync(join(dir, "cursor-traces"))
expect(files).toHaveLength(1)