[REV-1714] Use server-authoritative AI credit availability in the client - #14634
Open
warp-agent-staging[bot] wants to merge 8 commits into
Open
[REV-1714] Use server-authoritative AI credit availability in the client#14634warp-agent-staging[bot] wants to merge 8 commits into
warp-agent-staging[bot] wants to merge 8 commits into
Conversation
Consume the new User.aiCreditAvailability GraphQL field (warp-server - Mirror the AICreditAvailability schema types and add cynic bindings, a focused GetAICreditAvailability query, and a piggybacked selection on the workspace metadata query. - Hold the shared server decision on AIRequestUsageModel with last-known-good semantics on refresh failures; has_any_ai_remaining now returns the server decision once one exists and only falls back to the legacy local derivation before the first successful fetch. - Feed the state from exactly two paths: the workspace metadata refresh piggyback and coalesced targeted fetches on auth completion, API-key/credential changes, workspace selection changes, and add-on credit/overage changes. Reset on logout. - Map server denial reasons to prompt alert presentation and gate the AI Assistant zero-state/prepared prompts on the shared availability. Co-Authored-By: Oz <oz-agent@warp.dev>
…out of credits The server reports BYO capability at the policy level because personal API keys are stored only on the client. Since nearly every tier allows BYOK, capability-only availability (available with no credit source) would otherwise suppress out-of-credits messaging for everyone. Pair the server's capability-only answer with the one fact only the client knows: whether a usable BYO path actually exists (a stored key/custom endpoint/Grok subscription permitted by policy, or a team-managed custom LLM). Without one, capability-only availability is treated as out of credits for gating and prompt-alert presentation. An explicit server denial is never overridden by local key presence. Pairs with the server-side denial precedence fix in warpdotdev/warp-server#13369. Co-Authored-By: Oz <oz-agent@warp.dev>
…with local keys Follows the server-side semantics rework (warp-server#13369): available now means the server knows for a fact requests can run (a Warp credit source or a configured server-managed BYO path), so the client trusts it outright. An OUT_OF_CREDITS denial means the server found no path it can see - locally stored API keys are request-level parameters invisible to it - so the client supplies that one fact and permits AI when a usable local key exists (policy permitting). Delinquency and spend-limit denials are hard rejections that local keys never bypass. The team-custom-LLM client check is dropped: server-managed BYO paths are now reflected directly in the server's availability decision. Co-Authored-By: Oz <oz-agent@warp.dev>
The server now only vouches for BYO configs it can operate itself, so Bedrock local-chain setups (region-only, credentials resolved on the client) surface as OUT_OF_CREDITS. Refine that denial locally by treating loaded AWS credentials with Bedrock enabled as a usable inference path. Co-Authored-By: Oz <oz-agent@warp.dev>
…rver-authoritative-credit-availability # Conflicts: # app/src/workspaces/gql_convert.rs # app/src/workspaces/update_manager.rs # app/src/workspaces/update_manager_tests.rs # app/src/workspaces/user_workspaces.rs # app/src/workspaces/user_workspaces_tests.rs # crates/graphql/src/api/queries/get_workspaces_metadata_for_user.rs
Master added user-level purchase-policy tests (constructing GqlUser and driving on_workspaces_updated) and provider-credential telemetry on ApiKeyManager::set_provider_key. After merging the server-authoritative credit-availability change, those test paths now exercise the availability apply path and telemetry, so register the required singletons in the affected test harnesses and add the new ai_credit_availability field to the gql_user helper. Co-Authored-By: Oz <oz-agent@warp.dev>
The transcript render path now reads AIRequestUsageModel::has_any_ai_remaining (server-authoritative availability), which panicked in transcript_tests because the harness never registered that singleton (nor its AuthStateProvider / ServerApiProvider deps). Production always registers AIRequestUsageModel during app init (app/src/lib.rs), so no production path can hit this; register the singleton (and deps) in the shared transcript-test app builder. Co-Authored-By: Oz <oz-agent@warp.dev>
Drive the banner from the server-authoritative availability decision and refresh it when that decision changes. Rename the legacy request-limit helper to make its base-plan-only semantics explicit while preserving the few quota-specific consumers. Co-Authored-By: Oz <oz-agent@warp.dev>
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.
Summary
Supersedes #14352 with its conflicts resolved against current
master.Consumes the server-authoritative
User.aiCreditAvailabilityGraphQL field (warp-server #12935 / #13369) so the client no longer infers overall AI availability from stale request limits, grants, or workspace metadata.AIRequestUsageModelholds the server decision with last-known-good semantics. Prompt alerts, the buy-credits banner, AI Assistant, Agent Mode, and code review use the shared availability. AnOUT_OF_CREDITSdenial is refined by usable local API keys or loaded local-chain Bedrock credentials when policy permits; delinquency and spend-limit denials are hard rejections.Client behavior
AICreditAvailabilityGraphQL types with forward-compatible unknown enum handling.CreditAvailabilityUpdated.has_base_plan_requests_remaining()and narrows it topub(crate). Its remaining consumers are intentionally base-quota-specific: anonymous request-limit gates, overage refresh heuristics, default-model-switch presentation, and the pre-fetch fallback.Server dependency
Requires:
The server follow-up must deploy before this client change ships. Without it, a valid direct-federation Gemini Enterprise configuration can be reported as out of credits, or the client can be enabled and then receive an out-of-credits response when submitting.
Conflict resolution
Merged
origin/masterinto the source branch. Six files conflicted, all mechanical "both sides added a field / test" collisions between this change (ai_credit_availability) and master's user-level add-on-credits purchase policy (user_purchase_policy)—both were kept:app/src/workspaces/user_workspaces.rsapp/src/workspaces/gql_convert.rsapp/src/workspaces/update_manager.rscrates/graphql/src/api/queries/get_workspaces_metadata_for_user.rsapp/src/workspaces/update_manager_tests.rsapp/src/workspaces/user_workspaces_tests.rsMaster's new
gql_userhelper was extended withai_credit_availability, and affected workspace test harnesses register the telemetry and request-usage models required by the combined changes.Verification
cargo nextest run -p warp -E 'test(request_usage_model) + test(prompt_alert)' --no-fail-fast— 56 passed.cargo nextest run -p warp -E 'test(credit_availability) + test(request_usage_model) + test(prompt_alert) + test(update_manager) + test(user_workspaces)'— 171 passed after the master merge.cargo nextest run -p warp_graphql— 7 passed../script/formatcargo clippy -p warp --all-targets --tests -- -D warningscargo clippy --workspace --exclude warp_completer --all-targets --tests -- -D warningsManual decision-matrix validation
Validated with the client connected to a live local warp-server while forcing only the
aiCreditAvailabilityresolver response. Request middleware and admission logic remained production-identical.aws login; after credentials load, both disappear.available=true, null credit source): trusted without local credentials.The first live case exposed that the buy-credits banner still used base request counts even though the composer used authoritative availability. This PR now drives both from the same decision and includes focused banner coverage.
Gemini Enterprise end-to-end control
Using the real production resolver and an enterprise direct-federation Gemini configuration:
Computer-use screenshots
Originating thread: https://warp-dev.slack.com/archives/C0BDQDW8V5E/p1785680392740989
Conversation: https://staging.warp.dev/conversation/e786e128-f77e-4ff6-9a41-528e9eb60953
Run: https://oz.staging.warp.dev/runs/019fc2e3-2949-72e9-808f-7f6e05af09e9
Plans:
Co-Authored-By: Oz oz-agent@warp.dev
CHANGELOG-IMPROVEMENT: Out-of-credits, delinquency, and spend-limit states across AI surfaces now reflect the server's authoritative credit availability, so they stay accurate as your plan, credits, or API keys change.
This PR was generated with Oz.