cursor / cursor/cookbook

DAG runner idle timeout kills tasks during an in-progress SDK reconnect

Open
#59 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
4.1k
Forks
492
Avg merge
37m
Merged PRs (30d)
3

Description

Description

sdk/dag-task-runner (and the copied skill at .cursor/skills/dag-task-runner) wraps run.stream() with withTimeout(..., streamIdleTimeoutMs). The default idle window is 5 minutes. If no stream event arrives in that window, the task is marked ERROR as a stalled model.

Headless @cursor/sdk local runs keep enableAgentRetries: true by default. When the transport stalls, the SDK retries internally and emits nothing on the public stream. The runner cannot tell model silence from that reconnect, so it cancels a live retry and the canvas shows a dead task.

The same guard exists in both copies of run_dag.ts:

https://github.com/cursor/cookbook/blob/main/sdk/dag-task-runner/src/run_dag.ts#L363-L375

const timeoutForNext = Math.min(deadline - Date.now(), streamIdleTimeoutMs);
if (timeoutForNext <= 0) {
  throw new TimeoutError(`Task ${task.id} exceeded deadline of ${formatMs(taskTimeoutMs)}`);
}
const next = await withTimeout(
  iterator.next(),
  timeoutForNext,
  streamWaitTimeoutMessage({
    taskId: task.id,
    timeoutMs: timeoutForNext,
    streamIdleTimeoutMs,
  }),
);

Expected

While the SDK is reconnecting, the idle clock should pause. Idle should fire only on real model silence.

Suggested fix

Subscribe to a reconnect/retry signal (onConnectionStateChange / RETRYING) and skip the idle timer while reconnecting. Until @cursor/sdk forwards that hook, wire the runner to the helper in sdk/reconnect-signal (or an equivalent) so transport retries are not logged as task failures.

Related

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Compare the idle-timeout handling in sdk/dag-task-runner/src/run_dag.ts and .cursor/skills/dag-task-runner/run_dag.ts, then inspect sdk/reconnect-signal and the SDK retry signals described in the issue. Determine how the runner can distinguish reconnecting from model silence, and verify that both copies pause idle expiry during retries while still enforcing the overall task deadline.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.