Skip to content

A voice command is refused before it is sent if it would pass the daily budget - #20

Merged
AboveColin merged 3 commits into
feature/1.16from
voice-budget
Sep 24, 2026
Merged

AboveColin merged 3 commits into
feature/1.16from
voice-budget

Conversation

@AboveColin

Copy link
Copy Markdown
Owner

The voice agent checked only whether the day's budget was already spent. A command that started one token under the budget went through in full, so the day could end over the budget by one command.

The agent now does what contexts and AI Task do:

  • It measures the request with payload_bytes and estimates its tokens before the call.
  • It refuses when the estimate does not fit, and speaks the same "budget is spent" line as before.
  • It holds the estimate as a reservation while the call runs.
  • It passes the request size to record, so voice commands also update bytes per token.

Tests: test_a_command_that_would_pass_the_budget_is_not_sent and test_a_voice_command_teaches_the_estimate. 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 1 of the 1.16 work. Targets feature/1.16.

…ly budget

The voice agent only checked whether the budget was already spent, so the
last command of the day went through in full and could end it over budget.
It now estimates the command from its request size, as contexts and AI Task
do, holds the estimate while the call runs, and reports the size to the
tracker so the estimate learns from voice requests too.
…n error

The check refuses a command whose estimate does not fit, which happens
with tokens left. The line said the budget "is spent". It now says not
enough is left, in all 13 languages.

With no fallback agent, the reply was an action_done response. The Assist
dialog and a satellite read that as a command that went through. It is
now an error, no_intent_match for a sentence not understood and
failed_to_handle for the budget, a rejected key and no answer, as the
default agent answers.
@AboveColin
AboveColin merged commit 0723b2b 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