Repository navigation
fix(tasks): end an approval wait when the task's time limit passes - #1176
Draft
sosidudku1 wants to merge 2 commits into
Draft
sosidudku1 wants to merge 2 commits into
sosidudku1 wants to merge 2 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withmaxDurationMs), 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 astime_ceilingwith 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
src/agent/turn/approval-deadline.test.ts(fake timers: fires at the limit, repeats, stops on dispose, survives a throwing gate).Merge notes
src/agent/agent-loop.ts. KeeprequestStartedAt = Date.now()right beforeexecuteStep.Not yet checked on the second Mac.