Skip to content

Task budget exhaustion doesn't stop new planner rounds; set_goals revives timed-out tasks indefinitely (unbounded cost loop) #705

Done

Description

@Jejin

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)

  1. budgetStop (server/engine_budget.go:56, called from server/engine.go:1048 before 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.

  2. set_goals revives 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 to running, 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 calling set_goals/add_intent every round — and each call revives the task, including when the same in-flight round revives a task that a concurrent budgetStop just marked timeout moments earlier. Nothing cancels the in-flight planner call when settleTask fires, and nothing prevents its own goal-setting tool calls from undoing that settlement.

  3. No lifetime circuit breaker. isTerminalStatus/db.IsTerminal (db/tasks.go:86-88) does include timeout, 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 own set_goals tool). 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 is explorations.status leaving '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 budgetStop before starting it (not just the next worker's), or cap a single planner.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_intent calls once settleTask has started for that task.
  • Add a lifetime-spend circuit breaker: once a task's total llm_usage spend exceeds some multiple of its configured budget (e.g. 2-3x) without a finding, auto-transition the exploration to failed instead of leaving it open for 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

  1. github-actions commented on Nov 30, 2026

    @github-actions

    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.

  2. added
    bug
    on Nov 30, 2026
  3. added a commit that references this issue on Nov 30, 2026
  4. BaaRai commented on Nov 30, 2026

    @BaaRai
    Owner

    Fixed on main through #726 (merge 0529f6b) by @brixtonpham, shipping in 0.7.1.

    What changed:

    • A normal planner round only starts when the remaining task budget covers the planner estimate plus the next worker, and each round has its own turn allowance and usage meter.
    • Once lifetime spend passes the task budget plus the wrap-up reserve, the settle sequence skips the final planner round instead of spending more, so an over-budget task cannot keep buying rounds.
    • set_goals / add_intent automatic 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.
    • A task without a configured budget behaves exactly as before.

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions