Skip to content

fix(server): stop dropping scheduled runs, subagent messages, retries, PR watches and draft uploads - #5

Merged
greaber merged 14 commits into
grant/mainfrom
grant/server-limits
Nov 12, 2026
Merged

greaber merged 14 commits into
grant/mainfrom
grant/server-limits

Conversation

@greaber

@greaber greaber commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Several server rules silently dropped or abandoned work.

  • Scheduled tasks: a daily fixed-time task more than 10 minutes late (server down or asleep) was skipped until the next day. A missed occurrence now runs once when the server can run it; a backlog gives one catch-up, and a near-miss catch-up stands in for the next occurrence instead of running twice.
  • Claude subagent messages: early messages were dropped past 64 subagents / 256 messages each. Limits are now 4096 / 65,536 with a 64 MiB per-session budget; drops are logged.
  • Effect retries: session detach and terminal, preview, scheduled-task and attachment cleanups retry for about 10 minutes (backoff to 30 s) instead of ~1.5 s. A background cleanup waiting to retry no longer blocks the thread's later effects, so a failing detach can't delay the next turn. Turn-start-type effects are unchanged (they already fail visibly).
  • PR watching: no longer stops after 8 failed reads. It keeps watching with backoff (4/8/16/30 min), tells the agent once, sends a recovery notice, keeps that state across restarts, and ends with a notice only if the host says "not found" for 7 days.
  • Draft uploads: uploads referenced by a draft were deleted after 24 h. Fetching an upload's URL now refreshes it; the sweep deletes pending uploads untouched for 30 days (partial uploads still after 1 h); the web app refreshes all saved draft and stash uploads on load and daily.
  • The 24 h usage-limit first-arming cutoff is unchanged (a change was reverted: armed recoveries already resume at any age, now covered by a test, and removing the cutoff would mass-resume old threads).
Check SHA Result
vp test run src/scheduledTasks/ 14e3f59 114 pass
vp test run UsageLimitRecoveryWorker 14e3f59 6 pass
vp test run FoundationPersistence, EffectWorker, ThreadStop, RunFinalizationQueue, SelectionRestart.integration, ProviderSwitch.integration 14e3f59 182 pass
vp test run src/orchestration-v2/runtimeLayer.test.ts 14e3f59 129 pass
vp test run ClaudeAdapterV2 14e3f59 355 pass
vp test run attachmentStore, AssetAccess, GuestShareService 2ed4832 73 pass
vp test run src/lib/draftUploadKeepAlive.test.ts (apps/web) 14e3f59 pass
vp run check:changed 14e3f59 pass

Claude Opus 5.5 via Claude Code (T3 Code).

greaber and others added 13 commits November 11, 2026 12:28
A fixed-time task whose occurrence was more than 10 minutes late (machine
asleep, server down) was silently rescheduled to the next day, so the work
never ran.

Drop the grace window: any due occurrence now runs when the scheduler can run
it. The run's completion computes the next occurrence from the completion
time, so a backlog of missed days produces one catch-up run, then the task
continues on its normal schedule. Interval and one-time schedules already
ran late occurrences this way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…reset

A usage-limited thread was only armed for auto-resume while its reset time was
less than 24 hours in the past. If the server was down or the machine asleep
across that window, the pending recovery was dropped and the thread never
continued.

Remove the cutoff so a failed usage-limited thread is armed and resumed once
its limit has reset, regardless of how late the server sees it. Archived,
settled, and otherwise ineligible threads are still excluded by the existing
checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…them

Messages that arrive before their Claude subagent is registered are buffered
until its task_started. The buffer held at most 64 subagents and 256 messages
each, so a long early burst lost subagent output; evicted launch details
(model, effort, owner) were dropped without any log.

Raise the bounds to 4096 subagents and 65,536 messages each, append buffered
messages in place so a long burst stays linear, and log a warning when launch
details are evicted (message drops were already logged).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every orchestration effect gave up after 5 attempts with about 1.5 s of total
backoff, so a transient failure in session detach or thread resource cleanup
permanently abandoned the work (for example, leaving a provider process or
terminal running) with only a warning in the log.

Background effects that nobody waits on (provider-session.detach and the
scheduled-task, terminal, preview, and attachment cleanups) now retry 28 times
with exponential backoff capped at 30 s, about ten minutes in total, and the
final give-up is logged as an error. Effects a user waits on (turn start,
restart, interrupt, steer, answers, rollback, checkpoint capture, title
generation, delegated stop, restart continuation) keep the short budget:
retry backoff blocks the thread's later effects, and those types already show
their failure to the user after the last attempt. Non-retryable interrupt
failures still settle immediately.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After 8 failed reads in a row (about 16 minutes), the watch reactor stopped
watching the pull request for good, so an outage or a temporary permission
problem silently ended a watch the agent relied on.

Keep the watch instead. After 8 failures in a row the agent gets one notice
that reads are failing, and sweeps back off, doubling the wait from 4 minutes
up to 30 minutes; host change feeds still read immediately. When a read
succeeds again the agent is told it can read the pull request again. The
separate stop after 10 comment-only wakes in a row is unchanged.

The settle test now stops the watch it restarts: tests share one database,
and later tests' reactors used to end that watch by failing to read it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Attachments uploaded to an unsent draft or prompt stash were deleted 24 hours
after upload. Drafts live only on clients (web local storage, mobile state),
so the server had no way to tell that a draft still referenced the upload,
and a draft opened the next day lost its files.

Clients already ask the server for an upload's asset URL whenever a draft is
opened, a stash is restored, or a mobile draft is sent, to check the upload
still exists. That request now refreshes the pending upload's timestamp, and
the sweep deletes only pending uploads untouched for 30 days. Interrupted
partial uploads are still removed after an hour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 24-hour limit only applies to arming a recovery for the first time. A
recovery armed before the reset resumes however late the server sees it, for
example after the machine slept through the reset. Cover that case so the
scenario stays protected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A provider or model switch queues the old session's detach ahead of the new
turn's start, and the outbox kept every later effect on a thread behind one
waiting to retry. With background cleanup now retrying for about ten minutes,
a failing detach could hold the user's turn for that long.

Background cleanup effects (session detach and the thread resource cleanups)
that have failed at least once no longer block the thread's later effects
while they wait to retry. Before their first attempt they still run first, and
effects a user waits on, such as rollback, still block as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fixed-time run missed by almost a day ran on catch-up and then again at
its regular time minutes later.

When a scheduled fixed-time run starts, its next occurrence is now counted
from at least an hour after the start, so an occurrence due within that hour
is skipped. Runs on time are unaffected, since fixed-time occurrences are at
least a day apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arts

The failed-read state was held only in memory: a restart could repeat the
"cannot read it" notice and forgot to tell the agent when reads recovered. A
pull request the host keeps reporting missing was also watched forever.

The watch now records whether the agent was told reads are failing and when
the host first reported the pull request missing. A restart reads again but
does not repeat the notice, and the first successful read still sends the
recovery notice and clears the state. If the host keeps reporting the pull
request missing for 7 days, the watch ends with a visible notice. The notice
no longer promises a follow-up that might not come, and the test now covers
the 30-minute backoff cap.

Both fields are optional, so watches saved earlier still decode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Raising the per-subagent limits left the early-frame buffer able to hold
4096 subagents of 65,536 messages each, with no bound on total memory.

Frames buffered before their subagent registers now also share a 64 MiB
session budget, measured by serialized size. A frame that would exceed it is
dropped with the existing warning; released frames return their share.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The server keeps a pending upload for 30 days after a client last asked
about it, but the web client only asked when a draft was opened or a stash
restored. A draft left unopened for a month lost its uploaded files even
while the app was used daily.

On load, and then about once a day, the app now asks each connected
environment about the uploads that saved drafts and stash entries reference,
one at a time, which refreshes them on the server. The composer guide now
says how long unsent draft uploads are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Nov 11, 2026
…imits

# Conflicts:
#	apps/server/src/orchestration-v2/PullRequestWatchReactor.ts
#	apps/server/src/orchestration-v2/runtimeLayer.test.ts
#	docs/user/source-control.md
@greaber
greaber merged commit 7fdbc27 into grant/main Nov 12, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant