Repository navigation
fix: count unpriced paid fires against the budget and refuse userinfo in a local endpoint - #3
Merged
Conversation
… in a local endpoint Spend sums now count cost_usd_reported when the kit records one (6.26.0 and later), else cost_usd. A paid fire on a model claude cannot price (cost_usd null, cost_basis "unknown") now counts at the reported figure in the night and month budgets, --budget-remaining, --check, the run log and the morning report, which also notes such fires. Fires listed in local-fires.tsv still count 0, and older ledger lines keep working. ns_is_loopback_url now requires the authority to be exactly 127.0.0.1, localhost or [::1] (any case) with an optional numeric port, so a URL with userinfo, a percent-encoded @, a trailing dot, a longer host or a non-numeric port is treated as remote.
agent-kit-startup
deleted the
fix/budget-fail-closed-loopback-userinfo
branch
November 30, 2026 19:03
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.
Spend sums fail closed
Since Agent Kit 6.26.0, a fire on a model
claudecannot price recordscost_usd: nullwithcost_usd_reportedandcost_basis: "unknown". The spend sums read onlycost_usd, so such a paid fire counted as 0.lib/common.sh:ns_spendandns_repo_spendcount each ledger line atcost_usd_reportedwhen it is a number, elsecost_usd, else 0 (sharedNS_JQ_COST). This covers the night and month budgets,--budget-remaining,--checkand the report's Spend table. Lines from fires listed inlocal-fires.tsvare still skipped, so local fires count 0. Ledger lines in the older format still count.bin/night-shift: the per-fire cost inruns.tsvuses the same rule from theAGENT_KIT_RESULTline. It stays empty in local mode.bin/night-shift-report: a note under Spend gives the number of tonight's fires with an unknown cost basis.Stricter loopback check
ns_is_loopback_urlnow requires the authority (from://to the first/) to be exactly127.0.0.1,localhostor[::1], in any case, with an optional numeric port. Anything else counts as remote: userinfo, a percent-encoded@, a trailing dot, a longer host name, an empty or non-numeric port, or?or#after the host.ns_endpoint_labelprints a label only for a URL that passes this check, so it never prints userinfo.Tests
tests/test_cost.sh(new): an unpriced fire stops anapi-keynight whose ceiling it exceeds.--checkand the report count it. The month sum counts unpriced, old-format and priced lines once each. An unpriced local fire still counts 0.tests/test_local.sh: a table of accepted and refused endpoint URLs, plus end-to-end checks that a userinfo endpoint is refused and, when vouched for, is never printed.tests/fake/agent-kit: optionalpriced:Xandunknown:Xcost tokens emit the 6.26.0 fields. The default output keeps the older format.bash tests/run.sh: 227 passed, 0 failed.scripts/hygiene-scan.sh: clean.README ("Local model", "Cost comes from the backend") and
docs/config.mddescribe both changes.