Repository navigation
feat(agent-vault): report brokered requests for billing and handle the free limit - #503
Conversation
…missing plan - Count each brokered request (HTTP and MCP, after any hook allows it) and each database or SSH connection once - Every minute, and once at shutdown, seal the count into a report with its own id and send it to `POST /v1/agent-vault/proxy/usage`. A report that fails is resent unchanged, since Infisical bills each id once; new counts go into the next report. A day of unsent reports is kept in memory - Stop reporting quietly against an Infisical that doesn't have the route - On `AgentVaultNotOnPlan`, drop the session's credentials at once and answer its requests as `blocked` with `plan_required`. The proxy keeps running and brokers again once the org pays
|
💬 Discussion in Slack: #pr-review-cli-503-feat-agent-vault-report-brokered-requests-for-billing-and-hand Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel. |
PR overviewThe PR adds reporting of brokered agent-vault requests for billing and handling of the free usage limit. One issue has been addressed, and one response-size hardening gap remains. Usage-report responses are buffered without a body-size limit, so an oversized control-plane response, including an error reply, could consume excessive proxy memory despite the configured timeout. Open issues (1)
Fixed/addressed: 1 · PR risk: 3/10 Reviews |
[Critical impact] The PR reaches Agent Vault billing reports and session access across proxy traffic. Fix early removal of unsent usage reports before merging. Findings
|
…refresh - Rename the plan refusal to AgentVaultFreeLimitReached, answered as 403 free_limit_reached - Pass the server's message (limit and reset date) to the agent as the refusal body, with a hint to tell the user an admin can add a card under Usage & Billing or wait for the monthly reset - An OAuth refresh refused for the free limit drops the session's credentials and answers 403, not 502
- A route-missing 404 pauses usage reports for an hour instead of turning them off; counts and pending reports are kept - Drop a report only when Infisical named the refusal; keep it on an unnamed 4xx or a 408 - Shutdown sends session logs first, then the last usage report with 5 seconds and no retries - A database or SSH connection is billed on its first query or command, so one the server turned away costs nothing - Gate refusals on the HTTP door log once a minute per kind, sharing the SOCKS5 limiter - The free limit hint says "an admin"
scott-ray-wilson
left a comment
There was a problem hiding this comment.
Tested against Infisical/infisical#9475 running locally as cloud. One low-priority edge case below.
Description 📣
Adds usage reporting for Agent Vault billing and handles an org that used its free monthly requests.
Companion Infisical PR: Infisical/infisical#9475 (AGE2-335)
POST /v1/agent-vault/proxy/usage. At shutdown, session logs go first, then one last report with 5 seconds and no retriesdocumentationUrl), pauses reports for an hour and keeps the counts. A report Infisical refuses by name (such as a report older than 7 days) is dropped with a warning; an unnamed 4xx or a 408 from something in front of Infisical is kept and resentAgentVaultFreeLimitReachedfrom resolve or from an OAuth credential refresh, drops the session's cached credentials at once and answers its requests asblockedwithfree_limit_reached, passing on the server's message. The proxy keeps running and brokers again once the org adds a payment method or the month resetsType ✨
Tests 🛠️
# Here's some code block to paste some code snippetspackages/cmd/testdata/command_surface.json