Skip to content

bug(company-os): a finished subscription run is recorded failed by its notional dollar budget #20266

Closed

Description

@mrveiss

Problem

A heartbeat agent on a subscription login can have a run recorded as failed by its dollar budget, after the work has already run.

Evidence

Host log, 2026-10-31 16:45 Riga time, Gate 3 re-test: BudgetExhausted: spent=10.046427 limit=10.000000 raised from _ingest_adapter_usage. The owner raised the limit by hand, so it will recur.

From the code on main:

  • autobot-backend/llc/scheduler/heartbeat_scheduler.py:942 calls _ingest_adapter_usage after the adapter run has finished.
  • heartbeat_scheduler.py:947-965 converts tokens to a cost event with no check of the adapter's billing mode, and re-raises BudgetExhausted so the run is recorded FAILED.

So finished work is reported as failed, and the limit does not prevent the spend it is charged for.

Not known

Earlier re-test notes say these dollars are notional on a subscription login; this has not been verified. Whether the 16:45 run's own output was otherwise usable has not been read. That run reported $0.35 for a no-op resume (see #20247).

Decision needed

What a dollar budget means on a subscription login. Recommendation: record usage as tokens, do not fail a finished run on notional dollars, and let SubscriptionQuotaExhausted remain the real limit. An enforced budget should stop the next run, which is #19240.

Acceptance criteria

  • A finished run on a subscription login is not recorded FAILED because of notional dollar cost.
  • Usage from those runs is still recorded and visible.
  • A test covers both subscription and API-billed adapters.

Activity

  1. mrveiss commented on Nov 1, 2026

    @mrveiss
    OwnerAuthor

    Maintainer decision (2026-11-01): on a subscription login, record usage as tokens and never mark a finished run failed over dollars. SubscriptionQuotaExhausted stays the real limit, an enforced budget stops the next run (#19240), and API-billed runs do not change. Implementation follows in a PR linked here.

  2. mrveiss commented on Nov 1, 2026

    @mrveiss
    OwnerAuthor

    Maintainer decision (2026-11-01), option B: subscription runs record tokens and do not count against a dollar limit. Only a token limit or SubscriptionQuotaExhausted can stop them. This supersedes the earlier note that notional dollars still accrue. It goes in the same PR, #20222.

  3. mrveiss commented on Nov 6, 2026

    @mrveiss
    OwnerAuthor

    Closure evidence for #20266 (landed via #20222, merge d6899a3, ancestor of main). Gate 2: pipeline-scripts/check-issue-close-refs.sh 20266 -> clear.

    AC (verbatim) Evidence on main Test
    A finished run on a subscription login is not recorded FAILED because of notional dollar cost. autobot-backend/llc/adapters/claude_result_failure.py:run_billing reads apiKeySource from the init event; autobot-backend/llc/scheduler/usage_billing.py:ingest_run_cost calls ingest_cost_event(..., bill_dollars=not subscription) and swallows BudgetExhausted for subscription runs; autobot-backend/llc/services/budget.py:ingest_cost_event records cost 0 when bill_dollars=False autobot-backend/llc/tests/test_subscription_usage_20266.py::test_finished_subscription_run_over_token_limit_is_recorded_not_failed; autobot-backend/llc/tests/test_subscription_dollar_budget_20266.py::test_subscription_run_adds_no_dollars_keeps_tokens_and_does_not_block_next
    Usage from those runs is still recorded and visible. same ingest_cost_event path keeps tokens (tokens_in/tokens_out) with dollars at 0 test_subscription_dollar_budget_20266.py::test_subscription_run_adds_no_dollars_keeps_tokens_and_does_not_block_next; test_subscription_usage_20266.py::test_subscription_run_under_budget_records_normally
    A test covers both subscription and API-billed adapters. n/a (test AC) API: test_subscription_usage_20266.py::test_finished_api_run_over_budget_still_raises_budget_exhausted, test_subscription_dollar_budget_20266.py::test_api_run_over_dollar_limit_still_raises_and_blocks_next; subscription/API billing detection: autobot-backend/llc/adapters/tests/test_claude_billing_20266.py::test_login_without_api_key_reports_subscription, ::test_api_key_reports_api

    Also covered: a token limit still stops the next run (test_token_limited_subscription_budget_still_stops_the_next_run). Not part of these ACs: native AutoBot-agent runs are not charged to a budget at all, tracked in #20883.

    Note: the issue auto-closed at merge with its boxes unticked; they are ticked now against the evidence above.

  4. added
    needs-ac-evidenceClosed by a merge keyword; awaits an AC evidence table comment (#19520)
    on Nov 6, 2026
  5. github-actions commented on Nov 6, 2026

    @github-actions
    Contributor

    Landed in #20222, merge d6899a3cb3

  6. github-actions commented on Nov 6, 2026

    @github-actions
    Contributor

    Landed via the merge train (#20896, merge 4a0f0e62df) via #20222

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

    area: company-osWave 4 · cluster A — Company OS & LLC canvasbackendbugSomething isn't workingneeds-ac-evidenceClosed by a merge keyword; awaits an AC evidence table comment (#19520)phase:M2.6Budgets enforced and costs recordedpriority: high

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions