Skip to content

feat(claude-directsdk): opt-in extra_usage reserve before the first billed request - #425

Closed
salch-cred wants to merge 2 commits into
NousResearch:mainfrom
salch-cred:fix/398-extra-usage-reserve
Closed

salch-cred wants to merge 2 commits into
NousResearch:mainfrom
salch-cred:fix/398-extra-usage-reserve

Conversation

@salch-cred

Copy link
Copy Markdown
Contributor

What

extra_usage under ask/stop refuses 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). Under ask/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-inference get_usage probe. Unset, non-numeric, ≤0 or >100 all mean 100 — existing installs behave exactly as before. notify/allow never 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

…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
@salch-cred
salch-cred requested a review from teknium1 as a code owner November 18, 2026 19:16
…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.
@teknium1

Copy link
Copy Markdown
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. hermes plugins install NousResearch/hermes-official-plugins#claude-subscription-directsdk --force gets it now; hermes plugins update claude-subscription-directsdk will too once the catalog pin moves (in progress).

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.

2 participants