Repository navigation
feat: local billing mode for models served on your machine - #2
Merged
Merged
Conversation
config.env is sourced but not exported, so ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN written there never reached a fire. The loader now exports the endpoint and model-name variables the claude CLI reads. NS_BILLING=local runs a night against a model served on this machine: - refuses to start without ANTHROPIC_BASE_URL on a loopback host (NS_LOCAL_REMOTE_OK=1 vouches for a non-billing remote server) - strips ANTHROPIC_API_KEY and AGENT_KIT_CLAUDE_MAX_BUDGET_USD - passes no --budget-remaining and ignores the three budgets - records its fires in local-fires.tsv so every spend sum skips the price claude makes up for an unknown model README documents the mode as experimental, with the limits found so far. Refs #1
5 tasks
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.
Closes #1
What changes
config.envis sourced, not exported, soANTHROPIC_BASE_URLandANTHROPIC_AUTH_TOKENwritten there never reachedagent-kit countdown. The loader now exports the endpoint and model-name variables theclaudeCLI reads (ANTHROPIC_BASE_URL,ANTHROPIC_AUTH_TOKEN,ANTHROPIC_DEFAULT_{HAIKU,SONNET,OPUS}_MODEL,CLAUDE_CODE_SUBAGENT_MODEL). This applies to every billing mode.NS_BILLING=local. Fails closed: refuses to start withoutANTHROPIC_BASE_URL, or with a non-loopback endpoint unlessNS_LOCAL_REMOTE_OK=1. Fires run withoutANTHROPIC_API_KEYand without a per-tick cap; no--budget-remainingis passed and the three budgets are ignored.claudereports a price withcostBasis: "unknown", and the kit writes it to the cost ledger. Local fires are recorded inlocal-fires.tsvand every spend sum (loop,--check, morning report) skips their ledger lines, so switching back toapi-keylater in the month is not charged for money never spent.docs/config.md"Endpoint" table,config.env.example,plan-template.md.Answers to the issue's questions
config.env(fixed);subscriptiononly stripsANTHROPIC_API_KEY. A dedicatedlocalbilling mode was needed because budgets cannot apply.llama3.1:8b(32k context, Ollama) answered in one turn with no tool call and changed nothing. Qwen3.8 27B (Q4, integrated GPU) completed a trivial to-do end to end: 27 turns, 26 tool calls, 58 minutes, commit merged to the pre-production branch, plan exhausted.NS_MODEL_*andmodel=take the server's model names; theANTHROPIC_DEFAULT_*_MODELvariables coverclaude's own aliases.Verification
bash tests/run.sh: all suites pass, including the newtests/test_local.sh(36 checks: export from config, fail-closed guards, loopback look-alikes, no key / no budget flag / no tick cap in local fires, ledger exclusion across a billing switch, morning report).bash scripts/hygiene-scan.sh: clean.env -iso the gateway variables came only fromconfig.env; on the real ledger,--checkunderapi-keyshowed the local fires excluded.Not covered
No full night yet, only supervised single fires. A fire the kit reports as
okis not proof of work on a weak model (documented in the README).