Repository navigation
feat(claude-directsdk): opt-in extra_usage reserve before the first billed request - #425
Closed
salch-cred wants to merge 2 commits into
Closed
salch-cred wants to merge 2 commits into
salch-cred wants to merge 2 commits into
Conversation
…illed request The request that first crosses a plan limit is already billed; ask/stop only act on the next one. Add extra_usage_reserve_percent (e.g. 97): under ask/stop, refuse once an account-wide plan window reaches that percent, using the same zero-inference get_usage probe. Unset or invalid keeps 100, so existing installs are unchanged. notify/allow never probe. Refs NousResearch#398
…imit_event; declare and document it The reserve only took effect on a get_usage probe, which runs only with no current answer. After any turn the process holds the turn's own rate_limit_event answer (using_overage false below 100%) for up to 15 minutes, so a running gateway kept sending past the reserve until the plan wall: the setting worked only on a fresh process. The event summary now carries the fuller account-wide window's utilization (unifiedWindows five_hour/seven_day), and under ask/stop with permitted overage a window at the reserve counts as spilling. The refusal says it was the reserve. The setting is declared in plugin.yaml (Desktop settings form) and documented in the README; CHANGELOG line under Added.
Contributor
|
Thank you @salch-cred! This landed on main through #445, which stacked the 15 reviewed Claude subscription fixes on current main so the shared CHANGELOG lines conflicted only once. Your commits are kept as written, with your authorship; this PR's tip is 4f8b827. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
extra_usageunderask/stoprefuses only after the account is already drawing paid extra usage — the request that first crosses the limit is billed. For unattended runs (/goal, cron) that is one request too late (#398, item 1).Fix
Adds
extra_usage_reserve_percent(e.g.97). Underask/stop,observe_usage()treats an account-wide plan window as full once it reaches that percent, so the refusal happens before the first billed overage request, using the same zero-inferenceget_usageprobe. Unset, non-numeric, ≤0 or >100 all mean 100 — existing installs behave exactly as before.notify/allownever probe, so the setting cannot change their behaviour.This is item 1 of #398 only; the cross-process state, UI notice, model-scoped windows and fallback items are separate asks and are not included.
Verification
tests/test_extra_usage_reserve.py(5 tests): threshold parsing and invalid-value fallback, below-reserve not spilling, at-reserve spilling, and the default 100 boundary. Run with the existing extra-usage suite: 13 passed.Refs #398