Repository navigation
Description
Same family as #182 (a post-result rebuild refused because of something that changed nothing), but a different trigger and a different code path, so I'm filing it separately.
Cursor runs AwaitShell itself. The provider only sees its tool_call_started / tool_call_completed. In recordToolLifecycle (replay-safety.ts:174-193) a completion counts only if some exec carries the same call id. A timed-out wait usually is claimed that way, because Cursor's terminal-record polls name the Await call. But a bare sleep (block_until_ms only, no task) has no polls at all, and a wait whose polls don't name it isn't claimed either. Both end in mark("display-tool-lifecycle", false), which sets historyRebaseUnsafe. After that, any cut right after a tool result in that Run is refused as opaque-activity (language-model.ts:1457).
Repro: branch test/await-opaque-activity on my fork (8c2bd65, one test-only commit on main 2ea6994). It adds five cases to the post-result matrix in test/run-error-host.test.ts. Between the two host shells, Cursor runs an AwaitShell, then the Run is cut after the second result:
await-sleep: args{block_until_ms: 20000}, resultsuccess{complete{runtime_ms: 20000}}. Should rebuild; main refuses.await-timed-out: wait on a background shell, resultsuccess{still_running{task_id, runtime_ms, output_file_path, output_length}}, two terminal polls that don't name the call. Should rebuild; main refuses.await-named-poll: the same wait with polls naming the call. Main already rebuilds it.await-finished(the task'scompletewith an exit code) andweb-fetch(a call Cursor ran with a result history can't hold): must keep refusing, and do.
bun test test/run-error-host.test.ts on the branch: 77 pass, 2 fail (await-sleep, await-timed-out).
Model: the fixture uses composer-2.5. The real sleeps were Opus 5.5 (claude-opus-5-5) on OpenCode 2.2.6.
Debug log (CURSOR_PROVIDER_DEBUG=1, await-sleep on main):
display tool_call_started: callId=wait variant=await_tool_call
recovery: history-unsafe cause=display-tool-lifecycle sessionId=29c20291…
display tool_call_completed: no advertised OpenCode tool callId=wait variant=await_tool_call preferred=await advertised=[bash]
recovery: history-check hostSessionId=ses_result_history_await-sleep sessionId=29c20291… reason=opaque-activity execs=2 terminalReads=0 missingReads=0 editHandshakes=0 attachmentReads=0 results=2 pending=0
pull: pump threw (cleaning up): Cursor Run ended before turn_ended after visible output or stateful server activity; automatic retry unsafe (attempt 1/14)
Host log: a real bare sleep from our host (Opus 5.5, 2026-11-10). No task, no polls, and it ends exactly at its limit:
[2026-11-10T08:11:29.818Z] cursor wait: callId=toolu_015Z… blockUntilMs=30000
[2026-11-10T08:11:29.818Z] display tool_call_started: callId=toolu_015Z… variant=await_tool_call
[2026-11-10T08:11:59.819Z] display tool_call_completed: no advertised OpenCode tool callId=toolu_015Z… variant=await_tool_call
How often: rarely, to be honest. Our host logs from Nov 4 to 13 have 951 AwaitShells. 888 of them were claimed by a poll naming the call, and only 19 completed unclaimed: 9 full-length sleeps, about 5 timed-out waits whose polls didn't name them, and 5 that ended early or couldn't be told apart. None of those 19 was followed by a post-result cut in the same Run, so main didn't actually refuse a turn for this here. We hit it on our fork's path for a Run that ends while host tools run, where a fault-injection run in a VM refused a turn after two plain sleeps. The post-result path has the same gap; it just needs a sleep and a cut in the same Run.
Suggested fix: accept the two Await shapes that tell the model nothing history lacks, and validate them strictly on the wire:
- timed-out wait:
await_tool_callalone, args{task_id, block_until_ms?, regex?}, resultsuccess{still_running{task_id, runtime_ms, output_file_path, output_length, regex_requested?}}with noregex_matchorwake_reason; - bare sleep: args
{block_until_ms}only, resultsuccess{complete{runtime_ms}}withruntime_ms == block_until_ms.
Anything else (a finished task's exit code, an error, a wake reason, a short sleep, unknown fields) stays unsafe, as now. A matching lifecycle gets mark("display-tool-lifecycle", true) and isn't added to announcedCalls. With that (about 50 lines in replay-safety.ts, ported from our fork), the two cases rebuild, await-finished and web-fetch still refuse, and run-error-host, replay-safety, parallel-pump and backend-recovery all pass. Happy to send it as a PR.
Activity
fix(shell): rebuild past Cursor's own shell traffic and keep backgrou…
fix(shell): rebuild past Cursor's own shell traffic and keep backgrou…
fix(shell): rebuild past Cursor's own shell traffic and keep backgrou…