Skip to content

test(company-os-e2e): step 6 budget exhaustion races an unseen spend (spent jumps between read and ingest) #20830

Open

Description

@mrveiss

Problem

autobot-backend/tests/company_os_e2e/test_e2e_04_budget_and_pause.py::test_step_6_exhausted_budget_is_not_dispatched failed once on a merge-train PR and passed on a re-run of the same job at the same head, with no budget code in the train.

POST /budget/<agent>/ingest -> 402 {"detail":"Agent <agent> budget exhausted: spent=2400.000000 limit=1400.000000"}

_exhaust reads tokens_spent (400 here), sets token_limit = spent + 1000, then ingests the reported remainder (1000). The refusal shows 2000 tokens spent beyond the read value, so something wrote spend between the read and the ingest. quiesce() runs before _exhaust, so either a run it did not see was still spending, or the ingest path counts one event twice. Which one is not known.

Acceptance criteria

  • The cause is named with evidence (the writer of the extra 1000 tokens).
  • Step 6 does not race: the limit is set and the remainder ingested against a spend nothing else writes meanwhile, or the extra writer is a defect and is fixed.

Activity

  1. github-actions commented on Nov 4, 2026

    @github-actions
    Contributor

    needs-structure: this issue is missing:

    • a phase:M2.<k> label matching milestone M2 - Company OS workflow-ready: found none
    • a native parent issue (add one, or write Parent: #N in the body), unless this is an umbrella with sub-issues

    The label clears on the next issue event once all three are present (#19522).

  2. github-actions commented on Nov 8, 2026

    @github-actions
    Contributor

    Landed in #21209, merge 6b6e405eb3

  3. mrveiss commented on Nov 13, 2026

    @mrveiss
    OwnerAuthor

    Sighting: merge-train pull request #21475, head 2bef393, run 43396041148 — test_step_6_exhausted_budget_is_not_dispatched failed in its precondition (_exhaust): POST /budget/<agent>/ingest -> 402 budget exhausted: spent=2400 limit=1400, i.e. the spend moved by about 1000 between the read and the ingest although the agent had been paused and quiesced first. The same workflow passed on main at 0f14a1b and 81c4e35 the same morning. The failed job was re-run once; the result of the re-run will be added here. Note for whoever fixes this: the train carries #21446, which changes how a cancelled or recovered run releases its work (items return to ready and are re-offered to the same agent) — if the re-run fails again, check whether that makes a paused agent's in-flight run spend later than quiesce expects.

  4. mrveiss commented on Nov 13, 2026

    @mrveiss
    OwnerAuthor

    Follow-up to the sighting above: the re-run of the same job on the same head (2bef393, attempt 2) passed. One more intermittent occurrence of this race; no change in the code between the two attempts.

  5. github-actions commented on Nov 13, 2026

    @github-actions
    Contributor

    Landed via the merge train (#21479, merge 45f3000b9d) via #21477

  6. mrveiss commented on Nov 13, 2026

    @mrveiss
    OwnerAuthor

    Landed in #21477 (merge 45f3000)

    Criterion Evidence Ticked
    The cause is named with evidence (writer of the extra 1000 tokens) The read-then-ingest double charge is explained (an ingest answered before its commit was visible, so the next read and ingest charged twice) and removed by #21332's commit-before-answer in llc/api/budget.py:315. The separate sighting spent=1410 limit=1400 (about 10 tokens over) is NOT explained. no
    Step 6 does not race, or the extra writer is fixed test_e2e_04_budget_and_pause.py:43 _exhaust is one ingest of the remainder; cannot be shown from code that the race is gone, only watched across CI runs no

    Remaining

    • Explain the spent=1410 limit=1400 sighting (about 10 tokens over).
    • Watch test_step_6_exhausted_budget_is_not_dispatched on the next trains before ticking the second criterion.
    • Issue stays open (landed with Refs).
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

    bugSomething isn't workingneeds-structureMissing goal milestone, matching phase label or native parent (#19522)testing

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions