You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Scheduler: a fire whose run ignores the deadline cancel keeps its lease and slot (follow-up to #2588) #2955
Follow-up to #2588. That issue's main cause, a fire waiting on a stalled run in its origin session, is being addressed in #2631. This issue covers the other way a fire can stay in flight past its deadline: the fire's own run doesn't stop after the deadline cancel.
Problem
When a fire reaches its deadline, the watchdog cancels its run and logs scheduled fire overdue/degraded; termination unconfirmed; capacity quarantined. If the run doesn't stop (for example a provider stream or a tool that doesn't honor cancellation), then by design (#2277) the fire keeps three things until the run really ends:
its session lease, so a singleton schedule doesn't fire again;
its schedule's name fence;
one of the maxConcurrentFires slots (default 4).
The scheduler deliberately doesn't reap a live fire, and it shouldn't: the old run may still be changing the workspace. But if the run never ends, the schedule stays stuck until restart, and once all slots hold stuck fires, no schedule fires at all.
TestFireDeadlineNonclosingEventsKeepLeaseUntilRecovery covers this behavior with a test provider that ignores cancellation.
What to do
Audit the fire path for steps that can block without honoring the fire deadline. Start with makeFireFunc in internal/app/scheduler_fire.go and what it calls: placement and run admission, carried context, the run's event loop, settleFireTerminalSnapshot, FinishRun, CloseSession, EndScheduledRun, and RecordFire* against remote stores. The origin-session notices are out of scope here (fix(scheduler): reap hung fires past FireDeadline (Fixes #2588) #2631).
Check that provider adapters and tool execution stop promptly when the run context is cancelled. That includes the LLM resilience layer: a local mecated logs max_attempts=60 per_attempt_timeout=5m0s stream_idle_timeout=3m0s, so we need to know whether cancellation also stops retries right away.
Decide whether quarantined capacity needs a metric or an alert, so that operators see stuck fires before every slot is taken.
Out of scope
Changing the #2277 guarantees: no reaping or recording of a fire as finished while its run is still alive.
Done when
Every blocking point found in step 1 either honors the fire deadline or has its own issue.
A fire whose run is cancelled at its deadline with a real provider adapter ends and releases its lease within a bounded time, verified with a test.
I read the fire path and the run's cancellation on main, then measured the concrete points with local tests. #2958 fixes three of them. The rest stays open here.
Placement (ReserveSuccessor on the execution provider)
A placement that hangs holds the fire past its deadline. The claim stays pending and the schedule stops.
The fire deadline, already computed from the claim, now bounds placement and session creation too.
RecordFireStart / RecordFireProgress
A schedule store that hangs (measured through the real grpcdriver client) holds the fire. The context has no deadline.
A 10s bound per write. Both stay best-effort.
Engine save after a cancelled read batch (loop.go)
It used context.WithoutCancel, so it skipped the 5s sessionPersistenceTimeout. With a store that hangs, the run was still open after 15s.
It now takes the same bounded path as every other save of a cancelled run.
Deliberately not bounded
The terminal RecordFire in the scheduler keeps no timeout. While a claim is still pending (the fire failed before RecordFireStart, or that record was lost), giving up would leave it pending. A lease-backed scheduler quarantines a pending claim, so the schedule would stop for good. Waiting holds the slot only until the store answers. The PR review caught this, and #2958 documents it in the code.
Still open
A fire whose own run ignores cancellation. The dispatcher waits for every tool call with no timeout. Local Shell is bounded (SIGKILL to the process group, 5s WaitDelay). Remote runners, MCP SDK cancellation and foreground subagent trees are not verified yet.
Store calls under the name fence in the stale-fire reconciler (scheduler_reconcile.go) and in the one-shot re-arm (reArmOneShot) have no timeout. This is pre-existing.
The fire's terminal session settle (settleFireTerminalSnapshot → Persist) and its event-log appends have no timeout when the session store or the event log hangs.
A test with a real provider adapter showing that a run cancelled at its deadline releases its lease within a bounded time (this issue's "Done when").
Decide on a metric or alert for quarantined fire capacity.
Checked and bounded already: the provider path (the resilience layer stops on cancellation and starts no new attempt), event emission (released 1s after Run.Cancel), and teardown (EndScheduledRun, lease release and attachment close all have timeouts).
How the fix for the stalled schedule comes together
The schedule in #2588 stalls because a fire stays in flight, holding its lease, its name fence and a capacity slot, while it waits on something that never ends. The fix has two independent parts:
Once #2631 is merged too, the fix is complete: none of the steps we reproduced can hold a fire indefinitely any more. Everything else, including a run that ignores cancellation, stays tracked in the checklist above.
The remaining points from the checklist above moved to #2959. They are hardening for rarer failures and not needed for the stall in #2588. #2958 closes this issue once merged.
Activity
peppescg commentedon Nov 23, 2026
Audit results
I read the fire path and the run's cancellation on
main, then measured the concrete points with local tests. #2958 fixes three of them. The rest stays open here.Fixed in #2958
mainReserveSuccessoron the execution provider)pendingand the schedule stops.RecordFireStart/RecordFireProgressgrpcdriverclient) holds the fire. The context has no deadline.loop.go)context.WithoutCancel, so it skipped the 5ssessionPersistenceTimeout. With a store that hangs, the run was still open after 15s.Deliberately not bounded
The terminal
RecordFirein the scheduler keeps no timeout. While a claim is stillpending(the fire failed beforeRecordFireStart, or that record was lost), giving up would leave it pending. A lease-backed scheduler quarantines a pending claim, so the schedule would stop for good. Waiting holds the slot only until the store answers. The PR review caught this, and #2958 documents it in the code.Still open
Shellis bounded (SIGKILL to the process group, 5sWaitDelay). Remote runners, MCP SDK cancellation and foreground subagent trees are not verified yet.scheduler_reconcile.go) and in the one-shot re-arm (reArmOneShot) have no timeout. This is pre-existing.settleFireTerminalSnapshot→Persist) and its event-log appends have no timeout when the session store or the event log hangs.Checked and bounded already: the provider path (the resilience layer stops on cancellation and starts no new attempt), event emission (released 1s after
Run.Cancel), and teardown (EndScheduledRun, lease release and attachment close all have timeouts).peppescg commentedon Nov 23, 2026
How the fix for the stalled schedule comes together
The schedule in #2588 stalls because a fire stays in flight, holding its lease, its name fence and a capacity slot, while it waits on something that never ends. The fix has two independent parts:
Once #2631 is merged too, the fix is complete: none of the steps we reproduced can hold a fire indefinitely any more. Everything else, including a run that ignores cancellation, stays tracked in the checklist above.
peppescg commentedon Nov 23, 2026
The remaining points from the checklist above moved to #2959. They are hardening for rarer failures and not needed for the stall in #2588. #2958 closes this issue once merged.
fix(scheduler): bound the steps a scheduled fire waits on (#2955) (#2958