Repository navigation
fix(llmloop): count a grace-round task_done as completion - #1678
Conversation
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). |
The grace round after an exhausted budget offers only code_comment and task_done, and asks the model to call task_done when it has nothing further to report. That checkpoint was discarded and RunMainTask returned completed=false, so a file the model had finished was recorded as incomplete: scan wrote review_item_failed instead of a reusable review_item_done, and a later resume re-ran it. Report grace-round completion and return it. Stops that never run a grace round, and a task_done(FAILED), are unchanged. closes alibaba#1018
a585390 to
8334e96
Compare
NanaseInori
left a comment
There was a problem hiding this comment.
Propagating a successful grace-round task_done fixes the lost completion state. The scan caller checks completed before classifying a budget stop, so the retained stop reason does not turn that success back into a failure. The added tests cover successful completion, FAILED remaining incomplete, and a reusable scan checkpoint. No blocking issue found in the code review; tests were not rerun in this review.
|
Thanks @NanaseInori for the review and for double-checking the budget-stop interaction — much appreciated. I also ran the \internal/llmloop\ and \internal/scan\ tests on the current head and they pass. |
|
@JasonBuildAI Thanks for the focused fix. I agree that a successful grace-round I would like us to keep task completion and visibility of review limits separate, though. As you noted in the description, the current callers only handle the budget stop on the incomplete path. With this change, a single task can hit a limit, finish in the grace round, and report zero findings without a corresponding warning in the final result. The progress log alone does not cover JSON consumers, and there may be no subsequent task or round to trigger another budget warning. Could you include the following in this PR before we merge?
This does not require treating the task as failed or redefining |
A task that spends its tool-request rounds or token budget and then completes in the grace round reported success with no trace of the limit, so a zero-finding result could read as clean. Record a review_limit_reached warning with the stop reason and the round's verdict, and qualify the zero-finding message in text and JSON output. Completion, the reusable checkpoint, and budget_exceeded are unchanged.
|
Thanks @lizhengfeng101 — agreed on keeping task completion and limit visibility separate. I pushed a follow-up commit (
Nothing here redefines |
Description
ocr scanandocr reviewrun a grace round once the tool-request or token budget is spent. That round only offerscode_commentandtask_done, and its prompt tells the model: "Call task_done if you have nothing more to report." When the model did exactly that, the completion was dropped.runGraceRoundthrew away theTaskCheckpointandRunMainTaskreturnedcompleted=falseno matter what.So a file the model had explicitly finished was recorded as incomplete. Scan wrote
review_item_failedinstead of a reusablereview_item_done, the review manifest put the group into failed coverage, andocr resumere-ran a file that was already done (#1018).This change makes
runGraceRoundreport whether it executed a successfultask_done, andRunMainTaskreturn that as its result. Stops that never run a grace round (StopEmptyRounds,StopCompression) are untouched, and atask_done(FAILED)in the grace round still leaves the subtask incomplete, the same as in the main loop. TwoMainLoopStopcomments that described completion as implyingStopNoneare updated to match, since a grace-round completion keeps the budget stop that led to it.One consequence worth naming: when the aggregate token budget stops a group and the grace round then finishes it, that group completes, so the run no longer classifies it as failed(budget) or records the
token_budget_reachedwarning for it. That follows from the group actually finishing, and later groups are still gated on TotalTokensUsed(), so the budget itself is still enforced.One thing I deliberately left alone: the
--max-tokens-budgethelp text says a group over budget "is reported as failed(budget)". That is still what happens unless the grace round finishes the task, and the same wording is mirrored inaction.yml, the skill files and four translated doc pages, so rewording it felt like a separate change. Happy to send that as a follow-up if you want it tightened.Type of Change
How Has This Been Tested?
makeis not available on my Windows machine, so I ran whatmake checkandmake testrun, over the same package list:gofmt -s -l .andgo vetover the same 24 packages — both cleango test -race -count=1over the Makefile's 24 packages — all passscripts/verify-english-only.go— pass (648 files); the three touched files already carry the SPDX header and no new files are addedgo tool cover— 90.6% total, above the 90% thresholdNew tests:
TestRunMainTask_GraceRoundTaskDoneCompletes— atask_done(DONE)in the grace round now returnscompleted=trueTestRunMainTask_GraceRoundTaskDoneFailedStaysIncomplete— atask_done(FAILED)there does notTestDispatchSubtasks_GraceRoundTaskDoneCheckpointed— end to end through scan: the file gets a checkpoint,session.LoadResumeStatecan reuse it, and noscan_subtask_errorwarning is recordedBoth new tests fail on the unpatched code (the scan one fails with "all 1 file scan(s) failed") and pass with the fix.
make testpasses locallyChecklist
go fmt,go vet)AI disclosure: I prepared this change with AI assistance (OpenAI Codex, a GPT-5-based coding agent), at my own request. I have read and understood the whole diff, and I went over the added tests before pushing. The commit is not attributed to the AI, and I will answer review comments myself.
Related Issues
closes #1018
Note: #1019 also targets this issue and proposes a much wider change (cancellation and FAILED semantics). That PR has been conflicting since mid-September. This PR deliberately stays minimal: it only carries the completion state out of the grace round.