feat(account): expose quota status and quota-over-subscription precedence to agents - #660
Merged
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
Code Coverage ReportTotal Coverage: 50.1% Generated from commit: deafc99 |
The QuotaStatusResponse schema marks only used/percentage as required and carries no explicit unlimited marker, so a nil remaining bound does not mean unlimited. Only an explicit positive remaining now counts toward has_quota, so zero-quota accounts (all nil) are no longer reported as covered.
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
pcfreak30
marked this pull request as ready for review
September 1, 2026 10:02
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.
Adds
account_quotato the operation catalog, surfacing upload/download/storage usage and a derivedhas_quotasignal on the CLI (pinner account quota) and the MCP tool surface. Wires quota intopinner://account/statusand the auth service'sGetQuota.Encodes the "quota trumps a subscription" access rule in the agent guide and prompt templates: proceed when
has_quotais true regardless of subscription; only when quota is exhausted fall back toaccount_subscriptionand surface the subscription deep-link to the human.Summary
This pull request introduces a new
account_quotaoperation across the CLI, MCP, and agent guide surfaces. It exposes the user's quota status (upload, download, storage usage/limits/remaining) and establishes a clear access policy: quota trumps a subscription — if the user has any usable quota remaining, no subscription is required and agents should proceed without asking about one. Only when quota is exhausted should agents fall back to checking subscription status, and if not subscribed, they must surface the returned web-app deep-link for the human to subscribe (agents cannot subscribe on their behalf).Key Changes
New
account_quotaoperation (CLI + MCP)account_quotathat fetches per-dimension quota (upload, download, storage) viaAuthService.GetQuotaand derives ahas_quotaboolean (true if any dimension is unlimited or has positive remaining allowance).AccountQuotaResultwithhas_quota, per-dimension usage/limits/remaining/reserved/threshold/percentage, a human-readable message, and the web-appweb_urldeep-link for managing usage/subscribing.AccountOperationsalongsideaccount_info,account_subscription, etc.Auth service extension
GetQuota(ctx)to theAuthServiceinterface and implemented it inAuthServiceDefaultby calling the portal SDK'sclient.GetQuota(ctx).CLI wiring
--openflag foraccount_quotato open the usage page in a browser (same pattern asaccount_subscription).upload used=5 limit=100 remaining=95 (5%)), plus the covered/not-covered message and web URL.web_urlandhas_quota.MCP surface
Quota(ctx)no-op (returnednilvia TODO) in the MCPaccountStatusAdapterwith a real implementation that callsGetQuotaand returns a structured map (has_quota,upload,download,storage) under thepinner://account/statusresource. On error, it returns anerrorkey so the agent can see why quota is unavailable.Agent guidance and prompt templates
account_quotabefore paid/metered actions, proceed ifhas_quotais true, and only check subscription + surface web URL when quota is false.ens_publish_auth_status,setup_auth_status_check, andwebsite_auth_statusprompt templates with matching access-verification instructions (check quota first; only fall back to subscription when quota is exhausted; never subscribe for the human).Tests
accountQuotacovering: typed result with positive remaining →has_quota=true; all dimensions exhausted →has_quota=false; unlimited (nil remaining) →has_quota=true; service error propagation withaccount_quota:prefix.account_quota --json --openemits valid JSON withweb_urlandhas_quotaand no browser chatter on stdout.MockAuthServicewithGetQuotaexpectations, and created afakeAccountQuotaDepshelper for hermetic testing.Cosmetic cleanup