Repository navigation
Conversation
An expired event batch was removed and counted at the two-second notification deadline, so a short Session DO stall lost transcript text. Retry transcript batches after expiry while their own age is below a fixed ten-second cap, with a fresh two-second attempt each time. Route, outcome and other notifications keep one attempt. Pin one delivery identity and the same immutable payload on a batch at its first send, so the Session DO receipt deduplicates a replay after an ambiguous timeout. Add eventCount and attempts to the loss aggregate. Update docs/control-plane.md Forwarding and cover queue expiry, send deadline, identity stability and grace exhaustion in the dispatcher unit and integration tests.
A retried transcript batch could hold a session lane past an outcome's deadline, and across saturated lanes a retry could take the lane before another session's critical notification. Grace now yields: a batch is not retried while a route or outcome notification waits for the same session, a queued retry is dropped and an in-flight retry is aborted when one arrives, and a retried head never takes a lane ahead of another waiting session. Critical deadlines and single attempts are unchanged. Pin the delivery identity at admission and account its bytes in the byte budget at admission and coalescing, so the 8 MiB cap holds through send and retry. Only batches without an attempt coalesce, which keeps the payload immutable. Log each recovered timeout as a Sandbox notification retry warning with a stable event field, and record whether an expiry or yield drop may have reached the receiver, so a timeout is countable separately from a terminal dispatcher drop. Update the forwarding docs. Add tests for same-lane and saturated-lane yield, boundary byte accounting across send and retry, and a real Session DO replay after a lost response.
Four grace retries could hold every forwarding slot, so a route or outcome arriving after they started waited for a whole attempt. When retries occupy all four lanes, a new route or outcome now aborts one retry and takes its lane. Critical deadlines and retained per-session order are unchanged. Derive the loss remote status from whether the batch was sent before, not from the queue position at drop time, so a retried batch that later yields or expires in the queue reports an ambiguous remote result. Test critical arrival before and after all four slots enter grace and a yield after an earlier send. Wait for the replay's onEvents call to finish in the lost-response integration test before flushing and reading the transcript, so a broken replay cannot pass by reading before the duplicate write.
Freeing a retry lane did not decide who used it: an older transcript batch could take the slot ahead of the critical notification. Lane selection now serves route and outcome heads first, then regular heads, then grace retries, so the freed slot goes to eligible critical work without changing order inside a session. A critical session that is already sending cannot use a freed lane, so it no longer costs an unrelated retry. Yield only transcript batches: an expired route or outcome was recorded as yielded when critical work was queued for the same session. Signal replay completion from the second receiver call only, so a slow first call cannot mark the replay applied before it finishes.
This comment has been minimized.
This comment has been minimized.
chrarnoldus
left a comment
There was a problem hiding this comment.
bot: services/cloud-agent-next/src/control-plane/sandbox/notifications.ts:492: A batch that expired in the queue still has zero attempts, so fresh transcript events can merge into it and be dropped when an outcome makes the grace batch yield. Exclude grace batches from coalescing so fresh events keep their own delivery deadline.
bot: services/cloud-agent-next/src/control-plane/sandbox/notifications.ts:516: When an aborted grace retry would free enough bytes for a route or outcome, admission can still drop the critical notification because the retry holds its reservation until asynchronous cleanup. Recheck admission after the reservation is released while preserving the original deadline.
… reservation A batch that expired in the queue and entered grace still had no attempt, so fresh transcript events coalesced into it and inherited its old deadline, delivery identity and grace cap. Coalescing now skips any batch that started an attempt or entered grace, so fresh events keep their own deadline and are delivered even when the grace batch yields to critical traffic. An aborted grace retry also kept its byte reservation until its asynchronous cleanup, so admission could drop the route or outcome that preempted it at the byte cap. Preemption now releases the reservation synchronously, and the cleanup path does not subtract it twice.
|
bot: Fixed both findings in 7c2f33f.
docs/control-plane.md §Forwarding and the PR description are updated. Dispatcher unit 33/33, native-events 15/15, routes 106/106, typecheck, oxlint and oxfmt pass. |
Manual QA — T-116Untestable · tested
Test details and evidenceScenarios
Harness
Log evidence for the blockerThe UI reports the same step: "Loading session history — Failed — Workspace setup failed". The local stack also logs Problems foundNone owned by the task. The local stack cannot verify local user tokens: session-ingest answers Not tested
Post-deploy checks are recorded on T-116: the existing check for a live stall (no missing text, Verdict: untestable |





Why
When the service that runs agent sessions forwards a batch of transcript events to the per-session
coordinator, it allows two seconds for the call. During a short stall in that coordinator the call
times out, and the batch is counted as lost and thrown away. The user then sees a transcript with
missing text or tool output until the next event refreshes it. The same two-second budget also
covers waiting for one of the four forwarding slots, so a busy sandbox can lose a batch that never
even started. Recovering those batches is visible to users as transcript text that would otherwise
be missing.
This change gives a transcript batch a bounded second chance. If its call or its queue wait expires
while the batch is younger than ten seconds, it is sent again with a fresh two-second attempt. The
delivery identity (one UUID and its expiry) is created once when the batch is admitted and reused,
so a resend after an ambiguous timeout is deduplicated by the per-session coordinator's existing
receipt and each transcript delta is stored once. Grace never delays critical notifications: a
retry is not started, or is aborted, when a route or outcome update is waiting for the same session,
and a retried batch never takes a forwarding slot ahead of another waiting session. Route and
outcome notifications keep their single attempt, their original deadlines, and the existing queue
limits and eviction order.
Summary
total age is below
SANDBOX_NOTIFICATION_GRACE_MS(10 s). Each retry gets a freshbudgetMs(2 s) attempt deadline, capped by the remaining grace.
yielded), anin-flight retry is aborted, no retry starts while a route or outcome waits for that session, route
and outcome heads are served before regular and retried heads, and when retries occupy all four
forwarding slots a new route or outcome aborts one retry to get a slot unless its own session is
already sending. Critical deadlines are unchanged, route/outcome keep one attempt, and non-transcript
notifications are never yielded.
{ id, expiresAt }) is pinned when a batch is admitted, and its bytes arecounted in the 1,000-entry / 8 MiB budget at admission, coalescing, send and retry. Fresh transcript
events never coalesce into a batch that already started an attempt or entered grace, so they keep
their own deadline and identity. A retry that yields releases its byte reservation before the
critical notification is admitted.
NotificationLossgainseventCount(transcript events),attempts(largest number of sends onedropped batch reached) and
remote(ambiguouswhen the batch was sent at least once and may havereached the receiver,
not_attemptedwhen no send was attempted).Sandbox notification retrywarning with the stableevent: sandbox_notification_retryfield, the expiry phase, the attempt number and queue/senddurations. It is countable in Axiom and is not a loss.
docs/control-plane.md§Forwarding documents the grace, the yield rules, the pinned identity andthe new loss and retry fields.
Verification
DO and Session DO path, which is the closest reproducible stall without the manual stack:
delivers a transcript batch after a held send in its own lane expires,yields a queued transcript retry to an outcome waiting in the same lane,does not let transcript retries take lanes ahead of another session outcome,frees a retry lane for an outcome that arrives after all four retries start,frees the slot for critical work ahead of an older transcript batch,does not free a retry lane when the critical session is already sending,does not coalesce fresh events into a batch already in grace,releases an aborted retry reservation before admitting critical traffic,reports a yield after an earlier send as ambiguous,applies a transcript delta once when a grace retry follows a lost response, andcounts the pinned delivery identity at admission, send and retry.to the QA pass; this change was verified with the stalled-receiver harness above.
Visual Changes
N/A
Reviewer Notes
and stays far inside the Session DO's five-minute receipt retention. A retried batch can hold its
lane for up to ten seconds only when no route or outcome waits and no other session is ready; a
newly arriving route or outcome aborts one retry if retries occupy every slot. The constant is one
line.
is aborted when a route or outcome update arrives for the same session, and a new route or outcome
aborts one retry when retries occupy all four slots, so critical work uses a lane immediately.
Route and outcome deadlines and their single attempt are unchanged. The dropped batch is recorded
once as
yielded, withremotederived from whether it was sent before, not from where it wasdropped.
notifySessioninto the dispatcherbecause the dispatcher owns retries;
notifySessionnow forwards the pinned payload and no longercreates a new identity per attempt. The dispatcher is the only production caller.
entry/byte count is unchanged by that re-insertion, so no capacity eviction is triggered by a
retry; an entry at the byte boundary is accounted with its delivery metadata before admission.
can never absorb a later batch under the same receipt.