Skip to content

fix(tasks): end an approval wait when the task's time limit passes - #1176

Draft
sosidudku1 wants to merge 2 commits into
mainfrom
fix/ato-1367-approval-wait-time-limit
Draft

sosidudku1 wants to merge 2 commits into
mainfrom
fix/ato-1367-approval-wait-time-limit

Conversation

@sosidudku1

@sosidudku1 sosidudku1 commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

What

The loop checks the task's wall-clock ceiling only when a step starts, and a tool waiting for approval waits until someone answers (the gate has no timeout of its own). A desktop "Run overnight" task that reached an approval prompt with nobody there sat on it past its time limit until morning.

For a turn whose caller set the time limit (taskMaxDurationMs, which the task runner passes for a task with maxDurationMs), the loop now arms a timer for each step at the time the task has left. When it fires it denies the session's pending approvals as nobody's decision, with a plain reason, and keeps denying new ones every 5 s until the step ends. The next step sees the ceiling and writes the closing summary, so the run ends as time_ceiling with a report, not cancelled.

Why

Linear: ATO-1367 (it asked to check this; reading the code confirms it can outlive the limit, on main and rel/xp-build alike). The fix is agent side, so the desktop picks it up with the next agent sync.

Limits: ordinary chat turns are not affected. A /goal round gets the goal's time limit, so its prompts are denied once that passes too. Approvals raised by Fusion workers (their own sessions) are not covered.

How it was verified

  • New src/agent/turn/approval-deadline.test.ts (fake timers: fires at the limit, repeats, stops on dispose, survives a throwing gate).
  • Not checked live: Run overnight for 0.5 h with a task that needs approval, not answering.
  • Not run yet: lint, tsc and vitest go in one combined pass on the second Mac.

Merge notes

Not yet checked on the second Mac.

The loop checks the task's wall-clock ceiling only when a step starts,
and a tool waiting for approval waits until someone answers. A desktop
"Run overnight" task that hit an approval prompt with nobody there sat
on it past its limit until morning.

For a turn whose caller set the time limit (a task run), the loop now
arms a timer for each step at the time the task has left. When it fires
it denies the session's pending approvals with a plain reason, and keeps
denying new ones every 5 s until the step ends; the next step sees the
ceiling and writes the closing summary. Ordinary chat turns are not
affected. Prompts of Fusion workers (their own sessions) are not covered.

ATO-1367
Node runs a setTimeout delay over 2^31-1 ms after 1 ms, so a task time
limit of more than ~24.8 days denied every approval at once. The wait is
now split into hops of at most that, like request-deadline.ts. Adds a
real-timer test for 2^31 ms and a loop-level test of the wiring with and
without a task time limit.

ATO-1367

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant