Automatic managed-ledger offload triggers create redundant retry work Coalesce automatic…
- User
Automatic managed-ledger offload triggers create redundant retry work
Coalesce automatic offload triggers while an automatic offload is running. There must be at most one active automatic run and at most one follow-up run when additional triggers arrive. A follow-up must still process newly eligible ledgers, and explicit/manual offload futures must retain their existing behavior.
Interface
No new public interfaces are introduced.
- Assistant
Searching the codebase for automatic managed-ledger offload trigger handling.
- Assistant
Implementing coalescing for automatic offload triggers: adding state tracking and centralizing follow-up scheduling.
- Assistant
Implementing coalescing logic and tests.
- Assistant
Adding a test to verify coalescing behavior:
- Assistant
Automatic managed-ledger offload triggers are now coalesced so redundant retry work is avoided.
Problem
When automatic offload ran and more triggers arrived (e.g. ledger rollovers), each one scheduled its own 100ms retry via
scheduledExecutor. That could queue many overlapping retries even though only one offload can run at a time.Solution
Automatic triggers (
NULL_OFFLOAD_PROMISE) are coalesced into a single follow-up flag:- Early coalesce in
maybeOffloadInBackground— if offload is already running, setautomaticOffloadFollowUpPendingand return without scheduling work. - Coalesce on lock contention in
maybeOffload— same behavior when fails for automatic triggers.
- Early coalesce in
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.