Repository navigation
Description
Summary
A task whose exploration goal is never satisfied can loop indefinitely between timeout and running, running a full planner round every cycle, with no automatic circuit breaker on total lifetime spend. In our case one task accumulated ~18.4M tokens across 17+ settle/reactivate cycles (vs. a configured ARTEX_TASK_BUDGET_TOKENS=250000) with zero new worker claims after the first, before we manually intervened.
Version/commit: main @ 16d3a3f5 (self-built image, 2026-11-30)
What I ran
Several autonomous pentest tasks against external targets, with ARTEX_TASK_BUDGET_TOKENS=250000, ARTEX_TASK_BUDGET_TURNS=150, ARTEX_INTENT_BUDGET_TOKENS=30000. Multiple tasks (not just one) exhibited the same pattern: logs show restored N tokens from llm_usage climbing every cycle (e.g. 347,003 → 709,870 → 997,015 → ... → 18,377,554) while [worker work#N] claimed intent only appears once, at the very start of the task's life.
What I expected
Once a task's lifetime spend exceeds its configured budget, it should settle into a terminal state and stay there — not keep re-running full (expensive) planner rounds forever.
Root cause (traced in source)
-
budgetStop(server/engine_budget.go:56, called fromserver/engine.go:1048before each planner round) only checks whether at least one worker's estimated cost remains (DefaultWorkerEstimateTokens = 50_000/DefaultWorkerEstimateTurns = 10,agent/budget.go:31-32). It never estimates or reserves budget for the planner round's own cost before letting it start. If there's any budget left when the round begins,planner.Plan()runs its full open-ended tool-calling loop (add_intent,set_goals, ...) to its own natural stopping point, with no per-round ceiling tied to the task budget. -
set_goalsrevives terminal tasks unconditionally.server/orchestration.go:173:tsx.SetResumeTask(func() { s.reviveTask(t) }) // set_goals → pulls a completed/paused task back to running
reviveTask(server/goals.go:371-382) explicitly pulls a task out of any terminal state (done/failed/timeout) back torunning, by design, so a human (or the agent) adding a goal can resume stalled work. Because the exploration's top-level goal is never satisfied, the planner keeps callingset_goals/add_intentevery round — and each call revives the task, including when the same in-flight round revives a task that a concurrentbudgetStopjust markedtimeoutmoments earlier. Nothing cancels the in-flight planner call whensettleTaskfires, and nothing prevents its own goal-setting tool calls from undoing that settlement. -
No lifetime circuit breaker.
isTerminalStatus/db.IsTerminal(db/tasks.go:86-88) does includetimeout, but it's only "terminal" until the next revival, and revival is designed to be routine (used by both the UI "resume" action and the agent's ownset_goalstool). There's no check anywhere in this path for "this exploration has already spent N× its budget across its entire lifetime — stop reviving it." The only thing that reliably breaks the cycle isexplorations.statusleaving'open'(to'achieved'/'failed') — which nothing in this path does automatically when a goal turns out to be unsatisfiable within budget.
Suggested directions
- Reserve/estimate the planner round's own cost in
budgetStopbefore starting it (not just the next worker's), or cap a singleplanner.Plan()call's token spend independent of the task's overall remaining budget. - Cancel (or at least ignore the resume side-effect of) an in-flight planner round's
set_goals/add_intentcalls oncesettleTaskhas started for that task. - Add a lifetime-spend circuit breaker: once a task's total
llm_usagespend exceeds some multiple of its configured budget (e.g. 2-3x) without a finding, auto-transition the exploration tofailedinstead of leaving itopenfor the heartbeat/revival path to keep retrying.
Happy to share the full restored tokens log sequence or DB snapshot if useful — removed task/target specifics above since they're not relevant to the bug.
Activity
github-actions commentedon Nov 30, 2026
Thanks — this is a well-traced bug report, and the version/config details are helpful. To reproduce and verify the fix, please add: the complete startup/config environment (all relevant ARTEX_* values, especially planner/worker estimates and heartbeat/revival settings), whether migration db/migrations/0021_planner_progress.sql is applied, one affected task or exploration ID, and a DB snapshot or export showing status transitions and llm_usage totals. Also include the full log slice covering at least two settle→revive cycles with timestamps, the planner tool calls (set_goals/add_intent), and whether revival came from the UI resume path, heartbeat, or the agent itself. Please confirm how you measured “17+ cycles” and whether any manual action preceded the final stop. With those, we can attempt a deterministic reproduction and check the suggested budgetStop reservation, in-flight cancellation, and lifetime circuit-breaker directions.
🤖 automated reply from the repo bot. A human maintainer reads everything. Ping me in any comment with
@artex-bot.Merge pull request #726 from BaaRai/integr/705-planner-budget
BaaRai commentedon Nov 30, 2026
Fixed on main through #726 (merge
0529f6b) by @brixtonpham, shipping in 0.7.1.What changed:
set_goals/add_intentautomatic agent revival refuses timed-out, settling and budget-exhausted tasks. An operator resume from the console or the chat still works while no run budget is exhausted.The 18.4M-token case from the report is covered by the hard ceiling and the revival guard. The one documented limit: with a token-only budget and
MaxTurns = 0, a normal round's turn allowance stays unlimited, so it can consume the reserve before the provider's hard ceiling stops it; the effect is a skipped final judgment, not unbounded spend. That is in the README.Closing with the release.
fix(server,agent): enforce planner run budgets and stop revive loops (B…