fix(worker): pass DeferOperation through MemoryEngine.execute_task#1135
Merged
nicoloboschi merged 1 commit intomainfrom Apr 20, 2026
Merged
fix(worker): pass DeferOperation through MemoryEngine.execute_task#1135nicoloboschi merged 1 commit intomainfrom
nicoloboschi merged 1 commit intomainfrom
Conversation
PR #1105 added DeferOperation support in the worker poller (poller._execute_task_inner catches it and routes to _defer_operation without bumping retry_count or writing error_message). The outer dispatcher in MemoryEngine.execute_task, however, still had a generic `except Exception` that converted every exception — including DeferOperation — into a RetryTaskAt(60s). Result: a task deferred hours out (e.g. by a backpressure-aware validator raising DeferOperation to wait for a quota window) instead came back in 60 seconds with retry_count bumped, losing the "defer is not a failure" semantics. Fix: add `except DeferOperation: raise` alongside the existing RetryTaskAt passthrough. Test: new regression test exercises MemoryEngine.execute_task with a validator that raises DeferOperation from validate_retain, asserting the exception escapes intact.
nicoloboschi
approved these changes
Apr 20, 2026
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.
Summary
Follow-up to #1105. The poller catches
DeferOperationand routes it to_defer_operation(noretry_countbump, noerror_message), but theouter
MemoryEngine.execute_taskdispatcher has a broadexcept Exceptionthat converts every exception — includingDeferOperation— into aRetryTaskAt(60s).Net effect: a task deferred hours out (e.g. by a backpressure-aware
validator waiting for a quota window) instead came back in 60 seconds
with
retry_countbumped. The "defer is not a failure" semantics from#1105 were silently lost for any exception raised from inside an
executor.
Fix
One-line addition:
except DeferOperation: raisealongside the existingRetryTaskAtpassthrough. Paired import added.Test plan
test_memory_engine_execute_task_passes_through_defer_operationinjects a validator that raisesDeferOperationfromvalidate_retain, submits abatch_retaintask throughMemoryEngine.execute_task, and asserts the exception that escapes isDeferOperation(notRetryTaskAt)../scripts/hooks/lint.shcleanDeferOperationtests intest_worker.pyunaffected (they use a synthetic executor that doesn't exercise theexecute_taskwrapper)