Skip to content

Actions are refused before they are sent if they would pass the daily budget - #23

Merged
AboveColin merged 1 commit into
feature/1.16from
action-budget
Sep 24, 2026
Merged

AboveColin merged 1 commit into
feature/1.16from
action-budget

Conversation

@AboveColin

Copy link
Copy Markdown
Owner

The four actions (jev.noul, jev.choice, jev.score, jev.ask) did not check the daily budget. services._ask measured the request only to record bytes per token after the call. A script that loops on an action could spend without a limit, but site-docs/cost.md says that the check runs before the request.

The actions now do the same as contexts, AI Task and (after #20) voice:

  • roll_over, then estimate the request with payload_bytes and estimate_tokens.
  • If it does not fit, raise HomeAssistantError with the new translation key action_over_budget. The message names the estimate, what is left and the budget. The call is not sent.
  • Hold the estimate with usage.reservation while the call runs.

The new message is in strings.json and all 13 translations.

Tests: test_an_action_that_would_pass_the_budget_is_not_sent and test_an_action_holds_its_estimate_while_it_runs. Both fail on 1a6c968 and pass here.

Local gate: ruff, ruff format, mypy --strict, pytest (409 passed, 12 skipped, coverage 96.85%), config_flow 100%, mkdocs --strict, hassfest (0 invalid). EXIT 0.

Part of the 1.16 work. Targets feature/1.16. It does not depend on any other part.

… budget

jev.noul, jev.choice, jev.score and jev.ask never checked the budget. A script
that looped on an action spent without a limit. They now make the same check
as contexts, AI Task and voice: estimate the request, refuse it with a message
that names the estimate, what is left and the budget, and hold the estimate
while the call runs.
@AboveColin
AboveColin merged commit 649f8c3 into feature/1.16 Sep 24, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant