Skip to content

fix(agent): make budget exhaustion visibly incomplete - #49309

Closed
spiky02plateau wants to merge 1 commit into
NousResearch:mainfrom
spiky02plateau:fix/budget-exhaustion-finalizer
Closed

fix(agent): make budget exhaustion visibly incomplete#49309
spiky02plateau wants to merge 1 commit into
NousResearch:mainfrom
spiky02plateau:fix/budget-exhaustion-finalizer

Conversation

@spiky02plateau

Copy link
Copy Markdown
Contributor

Summary

Budget-exhausted turns now surface as visibly incomplete instead of letting a fluent model summary pass as a verified final answer. Both max_iterations and shared IterationBudget exhaustion return completed=false with structured budget metadata, and the final visible response is wrapped in runtime-owned wording that says the task is not verified complete and can be resumed with continue.

This keeps downstream behavior honest without introducing startup-context optimization or a new resume system: gateway resume markers stay uncleared, cron treats the run as failed, and final-send suppression no longer hides the deterministic incomplete-state warning after streamed/interim content.

Design notes

Concern Decision
Completion truth budget_exhausted=true, failure_reason="budget_exhausted", budget_used, and budget_max are emitted on every finalizer result.
User-facing response Model-authored summary text is demoted under “Progress summary from the model”; runtime wording remains the completion authority.
Gateway delivery Budget-exhausted responses bypass normal “already streamed” suppression so the warning reaches chat even after interim content.
Scope discipline The budget fix is independent of startup context audit code/config and does not add provider/model or auto-resume behavior.

Tests

  • python -m pytest tests/agent/test_turn_finalizer_budget_exhaustion.py tests/run_agent/test_turn_completion_explainer.py tests/gateway/test_restart_resume_pending.py tests/cron/test_scheduler.py -q -o 'addopts='
  • python -m py_compile agent/turn_finalizer.py agent/chat_completion_helpers.py gateway/run.py run_agent.py tests/agent/test_turn_finalizer_budget_exhaustion.py tests/run_agent/test_turn_completion_explainer.py tests/gateway/test_restart_resume_pending.py tests/cron/test_scheduler.py

Post-Deploy Monitoring & Validation

  • Validation window: first 24 hours after deployment; owner: Hermes ops.
  • Healthy signals: exhausted turns include budget_exhausted=true, completed=false, and user-visible text starting with Iteration budget exhausted; cron runs with exhausted budgets record failure rather than ok.
  • Log checks: search gateway/agent logs for iteration_budget_exhausted, max_iterations_reached, budget_exhausted, and Suppressing normal final send around exhausted turns.
  • Failure signals: budget-exhausted turns marked completed=true, cron jobs marked successful after exhausted turns, or chat users receiving only interim/tool-progress text without the deterministic warning.
  • Rollback trigger: any increase in normal successful turns receiving budget warnings, or plugin/gateway delivery errors caused by the new result metadata.

Compound Engineering
gpt--5.5

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P1 High — major feature broken, no workaround labels Jun 19, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks @spiky02plateau. The core data-loss in #8049 is now fixed on main via #50009 (merge commit 9f67ba1): the unguarded cleanup chain in finalize_turn no longer lets a trajectory/resource/SQLite failure escape run_conversation and discard the partial response.

This PR goes considerably further than the reported bug — ~670 lines reworking completion semantics (budget_exhausted metadata, runtime-owned "incomplete" wording, gateway final-send suppression bypass, cron PARTIAL handling). That's a meaningful design direction, but it's a separate feature from the silent-exit fix #8049 asked for, and it doesn't itself guard the cleanup chain. We'd rather not couple the budget-completion-truth redesign to this P1 bug.

Closing against #8049 since the data-loss is resolved. If you want to pursue the "visibly incomplete budget" behavior, please open a focused PR scoped to just that and we'll review it on its own merits — thanks for the thorough write-up.

@teknium1 teknium1 closed this Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P1 High — major feature broken, no workaround type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants