Handle ResumeResponse.is_done from the K-parallel backend - #164
Closed
yuxiang-wu wants to merge 1 commit into
Closed
Handle ResumeResponse.is_done from the K-parallel backend#164yuxiang-wu wants to merge 1 commit into
yuxiang-wu wants to merge 1 commit into
Conversation
The backend's resume endpoint can now finalize a run itself (promoting a scored-but-interrupted node meets the step budget), signalled by a new additive is_done field. That backend deploys before the CLI's parallel features, so today's CLI must handle it: previously a manual resume of such a run entered the task loop, saw the run completed, and reported it as stopped/failed. - is_done parsed defensively (absent -> False; unchanged behavior against an older backend). - Manual resume short-circuits on is_done: acquires the working-tree consumer lock, offers the best solution (skipping the apply with the standard message if the lock is unavailable), and exits successfully without entering the task loop. - _silent_resume returns RESUMED / ALREADY_COMPLETE / FAILED; the auto-resume wrapper treats ALREADY_COMPLETE as terminal success. - A 409 on result submit (run stopped mid-race) stays an error, never a completion — pinned by test. Ships last in the deploy order: supabase migration -> meta-agent -> this CLI patch.
Contributor
Author
|
Closing for now — this branch will be part of a single PR covering the complete parallelization feature once all phases are implemented. |
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.
fix: handle ResumeResponse.is_done from PR-2 backend (patch release)
The PR-2 backend's
/runs/{id}/resumecan finalize a run itself (promote ascored-but-interrupted node → step budget met → run flipped
completed, no runnablework), signalling it with a new additive
is_done: boolon ResumeResponse. Thisbackend deploys BEFORE the CLI's parallel features, so today's CLI must handle it.
Bug (pre-fix):
is_donewas ignored. Manualweco resumeentered thetask-polling loop, saw
run.status == "completed", and returnedOptimizationResult(success=False, reason="user_requested_stop")— reporting acompleted run as stopped/failed (
weco/optimizer.py:307-317, entered at:998).The silent auto-resume path (
_silent_resumereturning a bare bool) re-entered theloop and hit the same misreport.
Fix (
weco/optimizer.py):is_doneis parsed defensively — absent →False, so the CLI stays correctagainst an older backend (unchanged legacy behavior).
resume_optimizationshort-circuits onis_done: prints a "Run alreadycomplete" success message (matching the existing completion output), reuses
offer_apply_best_solutionto fetch/apply the winning code, and exitsTruewithout entering the task loop.
_silent_resumenow returns_SilentResumeOutcome{RESUMED, ALREADY_COMPLETE, FAILED};_run_loop_with_auto_resumetreatsALREADY_COMPLETEas terminalsuccess (fires
on_complete, returns acompletedresult, stops retrying) —mirroring how a normal is_done exits the loop.
Tests:
tests/test_resume_is_done.py(is_done true → no loop / success; is_doneabsent → legacy loop path; is_done false → legacy loop path) and two new cases in
tests/test_auto_resume.pyfor theALREADY_COMPLETEoutcome. Fully mocked, nonetwork. Run:
pytest tests/test_auto_resume.py tests/test_resume_is_done.py.Ships last in the deploy order (supabase → meta-agent → CLI).