Repository navigation
feat(mcp): an optional Usage domain so agents can read quota without root management - #1451
Merged
Juliusolsson05 merged 8 commits intoSep 27, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…root management (#1339) usage_read returns the same sanitized snapshot as the Usage screen and ac_usage_read (one shared readUsageSnapshotForTools, no force, the 30 s cache). Configurable on every provider, off by default, not gated. The tool-boundary test reads a recorded ac_usage_read answer that the manager supplies (testing/fixtures/usage, pending). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#1339) The manager's raw answer from the owner's machine (read in full: plan names, percentages, labels; no credentials). Pins that the recorded Grok error row reaches the agent as an error, not zero usage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # src/main/index.ts # src/mcp/runtime/BuiltInMcpHttpHost.ts
review a) An agent holding only Orchestration could mint the off-by-default usage domain for a child and read the quota back; usage now joins the parent-held- only set. sanitizeUsageError passed any message naming auth.json verbatim, including an fs error's absolute credential path; only Agent Code's own fixed auth.json messages keep their words, the rest is one curated sentence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…iew a) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…q132, security) sanitizeUsageError passed messages by prefix/substring (Keychain, '<Provider> auth.json ...', 'Grok login expired'), so a prefix-shaped error with a path or token tail passed whole to the usage MCP domain. It now keeps only the exact sentences Agent Code throws; everything else is fixed text. Pinned at the sanitizer, the real Usage reader's error row and the real usage_read tool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tructions with the domain (#1451 review c) - usageSnapshotForTools.test.ts drives the real readUsageSnapshotForTools over the real Usage service (only the provider reads replaced, with the recorded rows): the Grok error stays an error row, and two default reads hit the providers once. Dropping error rows (6 red) or a force default (1 red) fail. - main passes the reader itself, not a lambda, so no unpinned wrapper can add force. - usageTools.test.ts asserts the instructions ship WITH the domain (dropping them: 1 red) and types the fixture rows as recorded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Round 1 disposition at b8b7506 (a: FIX-BEFORE-MERGE, b: MERGE-READY, c: FIX-BEFORE-MERGE), plus steering q132. a
b
c (each fixed fail-first in b8b7506)
🤖 Generated with Claude Code |
Owner
Author
|
B6: the q132 security hold is lifted. sanitizeUsageError keeps only exact first-party sentences (FIRST_PARTY_USAGE_MESSAGES) and maps everything else to fixed text. It is batched in 1461. |
Juliusolsson05
changed the base branch from
main
to
integration/batch-2026-09-27-o
September 27, 2026 19:16
Juliusolsson05
merged commit Sep 27, 2026
e03147a
into
integration/batch-2026-09-27-o
2 checks passed
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.
Fixes #1339
Why
Orchestrating agents (the manager/worker fleet, review pipelines) spawn child agents across providers with no view of quota. Only root management's
ac_usage_readexposed usage, and that domain grants full app control and is confirmation-gated. The fleet found Grok at 100% only by accident.What
A new optional built-in MCP domain,
usage, with one read-only tool:usage_readreturns the same sanitized snapshot the Usage screen andac_usage_readshow: per provider, the window, percent used, severity, reset time and fetch time, plus per-provider errors. It covers Claude, Codex, Grok and OpenCode (z.ai).usageService.readUsageSnapshotForTools(the JSON round trip is the sanitization). Root management'susage.readcalls it too, so the two can never disagree.forceinput. A fleet polling with force would bypass the 30 s cache and hit every provider's quota endpoint on every call.usage_readtool (usageErrorBoundary.test.ts).Tests
src/mcp/runtime/usageTools.test.tsruns through a real MCP client against a recordedac_usage_readanswer (testing/fixtures/usage/, fetched by B6 from the owner's machine and read in full: no credentials). It checks:forceinput;persistence.test.ts:usageis off in the shipped defaults for every provider. That lives beside the renderer's list, so the node program doesn't import renderer files.src/main/usage/usageSnapshotForTools.test.ts(review c) drives the REALreadUsageSnapshotForToolsover the real Usage service, with only the provider reads replaced by the recorded rows:Main passes the reader itself rather than a lambda, so there is no unpinned wrapper where
forcecould be added.createBuiltInMcpServer.test.ts: a child cannot be grantedusageby a parent that does not hold it (review a).force: truedefault (1 red);npx tsc -bclean at b8b7506. The MCP, usage and settings suites pass 229/229 across 25 files.Merge notes
src/main/index.ts(imports) andBuiltInMcpHttpHost.ts(the dependency type) were resolved by keeping both sides.🤖 Generated with Claude Code