Skip to content

A run the token limit refuses pauses and goes on by itself, and no error reads as one a person must repair - #937

Merged
nambok merged 12 commits into
mainfrom
token-limit-pauses
Dec 1, 2026
Merged

nambok merged 12 commits into
mainfrom
token-limit-pauses

Conversation

@nambok

@nambok nambok commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A model call refused by the team's monthly token limit stopped the run as "CoderHelm met an error it doesn't know how to repair", headed "Look at what stopped the run, put it right, then press Retry" and "Needs a person". The run then waited for a person even after the month turned. The error classifier only knew the older wording of the limit ("limit exceeded"). Every model call now says "limit reached", so the refusal was read as an error nobody knew. Nothing warned before the limit, and new runs kept starting into it. A run whose ticket branch held a teammate's commits, with no pull request, stopped with the same frame.

This change makes the limit a typed pause that resumes by itself, from the step that was refused. New runs wait for room instead of starting into the limit. Admins are warned at 80% and 95%. A teammate's branch no longer stops a run. The generic frame can't be produced any more.

It builds on #924 (runs waiting on the usage limit go on by themselves) and #930 (typed hand-offs, OwnProblem). The branch merges both heads, so its diff includes their commits until they land. The change itself is the last commit. The dashboard half is CoderHelm/coderhelm#514 (merged: the paused run page and the 80% and 95% banner) and CoderHelm/coderhelm#527 (the runs list, the palette and the webhooks docs).

Changes

  • The limit is a known stop (common::token_room, run_recovery):
    • token_room::refusal reads both wordings of a refusal, wherever it sits.
    • The classifier gives it its own kind, Kind::TokenLimit, never Unknown.
    • usage_limit builds a typed Pause, kept on the run's waiting_on. Its one line: "Paused: this month's token limit is used up (40.3M of 40M). Resumes by itself on Dec 1, 00:00 UTC when the month turns, or as soon as an admin raises the limit." The page, the ticket and the record all say that line.
    • The run stays needs_input with the usage_limit hand-back, which Waiting runs go on by themselves, and texts say what actually happens #924's wake_limit_waits reads. The pause is never written as a person's step.
  • Resume from the checkpoint:
    • A pause keeps the run's continuation (stop_for_person and end_with call keep_resume_message) and never opens a stopped draft.
    • The limit's wake (token_room::wake_team, called from Waiting runs go on by themselves, and texts say what actually happens #924's wake_limit_waits) claims the run with one conditional write. It then sends that continuation: the same run, from its checkpoint, with its plan, branch and finished steps.
    • The gateway's retry-style wake leaves these runs to the in-place resume.
  • Not into the wall blind:
    • What a run takes is estimated from the team's last 30 days of runs: the median of each token part over the newest 20 finished runs of its kind, or of every kind when fewer than 3 of its kind finished.
    • A new run checks the room left before its first pass. When the room is short it waits as "Waiting for token room".
    • A run under way checks before building, and waits between steps rather than half way through.
    • Runs in progress hold what they still need, so new runs only take what is left. The wake starts runs paused half way first, then new runs while room is left.
    • Warnings go out at 80% and 95%, once each a month per limit, with the day the limit runs out at this month's pace (token_room::pace_line). The email templates gain the pace line. /api/usage gives warn_level and projected_at per limit for the dashboard's banner.
  • The month's turn:
    • A schedule at 00:00 and 00:01 UTC on the 1st sends the sweep, not the next 15-minute tick. The wake reads the new month's counters, so a pause from the month before goes on at once.
    • Saving a higher limit sends the sweep at once.
    • A paused run gets no "still waiting" reminder from the stuck-run sweep.
  • Tickets at the limit still start: a GitHub issue or Jira ticket that arrives while the limit is reached was dropped with a comment. It now starts, and the worker pauses its run at the start the same way, so it goes on by itself too.
  • The runs list and webhooks:
    • The runs list reads waiting_on (LIST_ATTRS), and RunSummary gains pause, so a paused run shows as paused in the list and the command palette (A paused run reads as paused in the runs list and the palette, and its last step is short coderhelm#527), never as waiting for an answer.
    • A pause sends the new webhook event run.paused, with the pause line in error. run.needs_input stays for waits a person ends. Both are in the event catalog, so the OpenAPI document and the docs' event list carry them.
    • The event scrubber redacted the word after "token", so a real pause line went out as "token [redacted] is used up". Plain words such as "limit" are no longer redacted; a credential after "token" still is.
  • A teammate's branch:
    • resolve_run_branch checks whether the ticket's branch holds commits CoderHelm didn't make with no pull request. If so, the run works on the first free (or its own) <branch>-N.
    • The teammate's branch is never touched.
    • One line on the run page and the ticket names the branch that was left. It is not a hand-off and not a failure.
  • No generic frame:
    • unknown_stop is gone. An error nobody classified is CoderHelm's own problem.
    • It is tried again with longer waits (30, 60, 120 seconds), then parked for the self-heal sweep with one plain line.
    • It raises an internal alert through A hand-off to a person is typed, and CoderHelm owns its own limits #930's own_problems::alert.
    • The self-heal sweep resumes only what this release parked this way, never an older failure.
    • rendered::person_text now refuses "doesn't know how to repair".
  • Runs already stuck: the limit's wake finds needs_input runs whose stored words hold a refusal (token_room::waits_on_limit). It resumes them in place after the deploy.
  • Incident case xg_token_limit_pauses_and_resumes, with its page. vo's guarantee is updated for unknown errors.

Verification

  • New tests, replayed on an invented bookstore:
    • a refusal mid-run becomes a typed pause and resumes from its step once the month turns;
    • the start check queues a new run, and a run under way waits before building;
    • runs in progress take the room first;
    • the 80% and 95% warnings each fire once, with the pace;
    • the month's turn wakes the paused runs;
    • a teammate's branch is left and the run starts on -2;
    • the generic frame is unreachable for every kind of error, and no producer is left in the code;
    • runs stuck this way before the deploy are picked up by their stored words.
  • Unit tests in token_room, run_recovery, run_fail, token_limits and the warning email, plus a stuck-run sweep test (no reminder for a paused run), the list's pause (only while the run still waits), and the webhook event (run.paused for a pause, run.needs_input for a person's wait, both matching the catalog's schema).
  • These pass:
    • cargo fmt --all --check;
    • rustfmt --check --edition 2021 worker/src/passes/incidents/*.rs;
    • cargo clippy -p common -p worker -p gateway --all-targets -- -D warnings;
    • cargo test -p common -p worker -p gateway;
    • the lambda tests;
    • brand_spelling.py and domain_examples.py.
  • The email goldens and docs/api/openapi.json were written again from the code.

nambok and others added 9 commits November 30, 2026 20:48
A hand-off is a PersonOnly from a closed set (a named permission an owner or
admin grants, a product decision, an approval the rules require, a credential,
work someone else holds, a real-world action), built only through
common::person_only. Words about CoderHelm's sandbox, allowlist, budgets,
tools, CI use, labels, tests or reads make an OwnProblem instead: an internal
alert and one run-page line. The person gate, hand-backs and a fix round's
NEEDS A PERSON line all go through it.

On its own pull request the reviewer blocks only on what a route can satisfy
(review_feasible). A pull request with no progress for a day is diagnosed,
retried along its next route and alerted (own_problems::check on the sweep).
Hand-offs are counted per team by reason, own problems by subject, with the
time each pull request spent blocked.

Incident case xd_own_limits_never_a_persons.
A run waiting on a person resumes when what it waits for arrives: a
comment or reply on its ticket (Jira, or a plain comment on the GitHub
issue), access granted on GitHub or a repository turned on, or usage
limits saved that allow runs. Wait actions name the one thing to do and
where, never "then press Retry".

The wrong-repo note names the `Repo:` line and cuts its reason at a word.
Tests-and-scope notes no longer quote the coding model's instructions.
Fix rounds get update_pr_description with the feedback round's guard.
PR labels are CoderHelm's to add, and an unblock never ends in "or run
the command yourself". The updater waits out a busy stack and retries a
rollback caused by throttling by itself; a failed update stack in another
account gets one AWS admin action. person_text guards each of these texts.
…elves

Runs waiting on the usage limit start again from the 15-minute sweep once
the team's limit allows runs, so a new month resets them. A run whose
change closed goes back to waiting when the change is reopened, and goes
on when it merges. An answered approval resumes the same run with the
work it kept. An alert run resumes when its alert fires again and closes
when it clears; its wait says what to do first, then Retry on the run page.
…ange's stop is read as one

- A wake (gateway event or the worker's limit sweep) that marked the waiting
  run superseded but couldn't queue its new run puts it back to waiting, with
  the status key and ending it had, only while it still holds that wake's
  write (common::run_wake::put_back). The ticket is serialized before the
  write, so only the send can fail after it.
- A woken security fix run starts as Retry starts it: a new request for its
  unit's findings (security::retry_event), not its ticket again.
- The change-wait sweep reads a run as "its change closed" only when its wait
  is that stop (change_wait::waits_on_close). A run keeps the change it
  waited on after it went on, so a later question, approval or person's stop
  is never overridden.
- A comment no longer restarts a run a person stopped or put back to draft
  (HumanOnly::PersonAction); only that person's Retry or ready does.
- A label item that names production, a release or a publish in any word
  (deploy-prod, release, CI:DEPLOY_PRODUCTION) stays the team's call.
- An update stack still rolling back (_IN_PROGRESS) is told to wait, never
  to update again or delete.
- one_way finds its cut in an ASCII-lowercased copy, so the offset is
  always a char boundary of the text it cuts.
…ror reads as one a person must repair

A model call refused by the team's monthly token limit ("limit reached")
was read as an error nobody knew, so the run stopped as "an error it
doesn't know how to repair ... put it right, then press Retry" and waited
on a person past the month's turn.

- The refusal is a typed pause (common::token_room, Kind::TokenLimit):
  the run keeps its continuation and resumes in place, from the step that
  was refused, when the month turns or the limit is raised. #924's
  wake_limit_waits hands these waits to token_room::wake_team.
- New runs wait for token room when what is left is less than a run of
  their kind takes; a run under way waits before building; runs in
  progress come first on what is left.
- Warnings at 80% and 95%, once each a month, with the day the limit runs
  out at this pace; /api/usage gives warn_level and projected_at.
- A schedule at 00:00 and 00:01 UTC on the 1st sends the sweep; a saved
  limit sends it at once; a paused run gets no reminder.
- A teammate's branch is left as it is: the run works on <branch>-N and
  says so once.
- An error nobody classified is CoderHelm's own problem: retried with
  longer waits, then parked with an internal alert (#930's own_problems);
  the generic frame is gone and person_text refuses it.
- Runs an older release stopped this way are found by their stored words
  and resumed after the deploy.
- Incident case xg_token_limit_pauses_and_resumes.
coderhelm[bot]

This comment was marked as outdated.

…nds run.paused

- RunSummary gains pause (the list reads waiting_on), and the search the
  command palette uses carries it too, so a run paused on the token limit
  is never listed as waiting for an answer.
- A pause sends the new webhook event run.paused, with its line in error;
  run.needs_input stays for waits a person ends. Both are in the catalog,
  so the OpenAPI document lists them.
- The event scrubber no longer redacts the plain word after "token"
  ("token limit"); a credential after it still is.
coderhelm[bot]

This comment was marked as outdated.

@coderhelm
coderhelm Bot dismissed their stale review December 1, 2026 04:45

Superseded by CoderHelm's latest review

@coderhelm

coderhelm Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Auto-merge
Merged by hand. Nothing left to do.
Commit into main. Merges on its own once every item is done.

coderhelm[bot]

This comment was marked as outdated.

Conflicts with #924's merged commits are resolved on this branch's side:
the token-limit pause replaces the unknown-error stop and widens the
limit sweep's filter. The tree equals main plus this branch's own two
commits.
coderhelm[bot]

This comment was marked as outdated.

@coderhelm coderhelm Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved with notes 40c9afe (merged)

@nambok
nambok merged commit 185aa99 into main Dec 1, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ch-review CoderHelm reviews this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants