Skip to content

feat(agent-vault): report brokered requests for billing and handle the free limit - #503

Merged
saifsmailbox98 merged 5 commits into
mainfrom
saif/age2-335-add-agent-vault-paywalls-from-the-pricing-page
Nov 16, 2026
Merged

saifsmailbox98 merged 5 commits into
mainfrom
saif/age2-335-add-agent-vault-paywalls-from-the-pricing-page

Conversation

@saifsmailbox98

@saifsmailbox98 saifsmailbox98 commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

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)

  • Counts each brokered request (HTTP and MCP, after any hook allows it), and each database or SSH connection once, on its first query or command, so a connection the server turned away costs nothing
  • Every minute seals the count into a report with its own id (split into several when it is over 1,000,000, Infisical's per-report limit) and sends it to POST /v1/agent-vault/proxy/usage. At shutdown, session logs go first, then one last report with 5 seconds and no retries
  • A failed report is resent unchanged, since Infisical bills each report id once; counts made after sealing go into the next report. A day of unsent reports is kept in memory
  • Against an Infisical without the route (404 with documentationUrl), 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 resent
  • Gate refusals on the HTTP door log once a minute per kind, sharing the SOCKS5 limiter
  • On AgentVaultFreeLimitReached from resolve or from an OAuth credential refresh, drops the session's cached credentials at once and answers its requests as blocked with free_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 resets

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

# Here's some code block to paste some code snippets

  • New or changed commands follow CLI.md, and new commands and flags are recorded in packages/cmd/testdata/command_surface.json
  • Updated AGENTS.md files (if needed)
  • I have read the contributing guide, agreed and acknowledged the code of conduct. 📝

…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
@infisical-review-police

Copy link
Copy Markdown

💬 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.

@linear

linear Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

AGE2-335

AGE2-377

@saifsmailbox98
saifsmailbox98 marked this pull request as ready for review November 13, 2026 23:15
@veria-ai

veria-ai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

The 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

Comment thread packages/agentvault/proxy.go Resolved
Comment thread packages/api/agent_vault.go Resolved
@greptile-apps

greptile-apps Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5 Tier: plus

[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

  1. P1 Usage reports are dropped early ▶

Summary

Adds Agent Vault usage reports and handles organizations that reach their free monthly limit.

  • Agent Vault counts brokered work and sends usage reports to Infisical.
  • Agent Vault blocks sessions when Infisical reports the free monthly limit.
  • Repeated refusal logs now share a limit across HTTP and SOCKS5 doors.

Reviews (5) · Last reviewed commit: "fix(agent-vault): split a minute over 1,..." · Reviewed by Greptile

Comment thread packages/agentvault/proxy.go Resolved
Comment thread packages/agentvault/usage.go Resolved
Comment thread packages/agentvault/run.go Resolved
Comment thread packages/agentvault/discovery.go Resolved
…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
@saifsmailbox98 saifsmailbox98 changed the title feat(agent-vault): report brokered requests for billing and handle a missing plan feat(agent-vault): report brokered requests for billing and handle the free limit Nov 14, 2026
- 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"
Comment thread packages/agentvault/native_logger.go Resolved

@scott-ray-wilson scott-ray-wilson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested against Infisical/infisical#9475 running locally as cloud. One low-priority edge case below.

Comment thread packages/agentvault/usage.go Resolved
Comment thread packages/agentvault/usage.go Resolved

@scott-ray-wilson scott-ray-wilson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@saifsmailbox98
saifsmailbox98 merged commit 3a894da into main Nov 16, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants