Repository navigation
fix(server,agent): enforce planner run budgets and stop revive loops (#705) - #714
Closed
brixtonpham wants to merge 1 commit into
Closed
brixtonpham wants to merge 1 commit into
brixtonpham wants to merge 1 commit into
Conversation
Owner
|
Landed on main through #726 (merge The commit is applied with your authorship. Three corrections were added on top after review:
Verification: Shipping in 0.7.1. Closing this PR in favour of #726 so the credits and the changelog stay in one place. |
menotbobbybrown
pushed a commit
to menotbobbybrown/ARTEX
that referenced
this pull request
Nov 30, 2026
Review of BaaRai#714 found three issues before it could ship in 0.7.1. The Main Agent chat path used reviveTaskFromAgent, which refuses a timed-out task by logging only, so an operator could no longer resume from the chat and got no explanation. The chat is an explicit operator turn: it uses reviveTask like the console again, and the admission guards still refuse a settling or budget-exhausted task. Automatic agent revival through delegateToTask keeps the stricter guard. TestBudgetStopReservesPlannerRoundCost pre-marked the wrap-up before calling budgetStop, so it passed because wrap-up was already set, not because the planner+worker reservation worked. It now calls budgetStop from Plan alone, with a bounded context that only shortens the settle wait. README documents the planner+worker reservation, the skipped final judgment past the hard ceiling, and which revivals are refused. Verified: gofmt on the committed blobs, go build ./..., go vet ./..., and the full ./agent ./server suites on disposable PostgreSQL 16, including TestHardExhaustedBudgetSkipsFinalPlannerRound.
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.
Fixes #705
Summary
agent/budget.go,agent/planner.go,agent/planner_progress.go,server/engine_budget.go,server/engine.go):BudgetLedger(PlannerEstimate) and exposeBudgetState.Plan(reserving both the next planner round and worker estimate above the wrap-up margin) andBudgetState.HardExhausted(spent >= task + margin).PlannerMeter(StartPlannerRound),Planner.turnCap(ctx),plannerBudgetHooks(blockingadd_intent,set_goals,set_constraints, scope changes, and active probing tools on forced wrap-up, and non-judgment tools once exhausted), andplanningProviderhard-ceiling refusal (ErrTaskBudgetExhausted).budgetRound.WrapUpas a final round inPlanner.PlanandplanOnceso compliant 0-intent budget wrap-up rounds are not rejected bycheckPlanningProgressand retried, and stop retries onErrTaskBudgetExhaustedor exhausted round meters.server/engine_timeout.go):budget && e.budgetHardExhausted(t.ID), cancel in-flight execution immediately (AbortSettleDrainTimeout) and skiprunFinalPlannerRoundcompletely (0 additional LLM calls).server/goals.go,server/orchestration.go,server/server.go):admitTaskWhen(unders.concMu), reject admission while in-flight settlement is active, reject automatic agent revival oftimeouttasks (reviveTaskFromAgent), and reject reviving terminal tasks whose run budget is already exhausted (budgetBlocksPlan), while preserving explicit UI revival of timed-out tasks when no run budget is exhausted.agent/budget_test.goandserver/engine_budget_test.go, plus aCHANGELOG.mdentry.Verification
#705before fix:TestHardExhaustedBudgetSkipsFinalPlannerRoundfailed by enteringrunFinalPlannerRounddespite347,003 / 250,000tokens spent.gofmt -lon all modified.gofiles — cleango build ./...andgo vet ./...— passedgo test -count=1 -race ./server/... ./agent/...— passed (server50.2s,agent6.7s)